Blackbeard, Brownbeard, and Redbeard as team Segfault go YARRRR, before Redbeard joined the jury. Every year, the Be A Pirate Competition is held. This year, Captain Redbeard has become part of the jury. While he does enjoy being a part of the jury, it also means he cannot participate, and thus cannot win the coffer of gold dubloons reserved for the winner.
Now he could, like many of his fellow jury members, pocket a few gold coins every once in a while. But Captain Redbeard has a better plan: his friends (Captain Brownbeard and Captain Blackbeard) are still participating this year, and they agreed to share some of the bounty if he helped them win.
The next task in the competition is finding a treasure on an island. Participants are given a map on which the treasure is marked with a big 'X'. However, to make things more interesting, there are a number of false 'X's to lead pirates astray. Captain Redbeard would like to somehow indicate which treasure marker leads to the actual treasure, but he has no opportunity to directly tell his friends.
But he has a plan! Each jury member will add a single false 'X' to the map, and he made sure to be last in line. By cleverly placing this final 'X', he can communicate the location of the real treasure to his friends through a previously established protocol.
If you help Captain Redbeard design and implement such an algorithm, he will award you with one large gold dubloon balloon.
This is a multi-pass problem. Your program will be invoked two times.
For each pass, the input consists of:
If your role is "captain", the treasure map contains precisely one '#', and it is guaranteed that $$$n \gt k^2$$$ where $$$n$$$ is the number of unmarked land tiles, and $$$k$$$ is the total number of treasure markers, including the one pointing to the actual treasure.
If your role is "matey", the treasure map is the same map that you received as "captain", but with the '#' replaced by 'X' and an additional 'X' placed at the coordinates output by your program as "captain".
A testing tool is provided to help you develop your solution.
If your role is "captain", output the treasure map from the input, with exactly one piece of unmarked land ('.') replaced by an additional treasure marker ('X').
If your role is "matey", output the treasure map from the input, with exactly one treasure marker ('X') replaced by the character '#', pointing to the actual treasure.
< captain < 2 3 < ~~. < ~.# > ~~X > ~.#
< captain < 4 5 < ~~.X~ < .X..~ < ..#.. < ~..~~ > ~~XX~ > .X..~ > ..#.. > ~..~~
| Name |
|---|


