kredit
Professor Djuric: Hellooooo!
Dragance: Good afternoon Professor, It's Dragance.
Professor Djuric: What are you doing, boy?
Dragance: I was just walking in the park and when I arrived at the fountain, I got an idea
about the problem we were talking about...
Professor Djuric: Did you?
That is how the phone conversation continued, which lasted for K minutes, and who knows how much longer it would have lasted if Dragance did not run out of battery. Dragance immediately went to charge his phone, and he went to the nearest electrical outlet in the park to plug in his charger. As soon as he arrives and plugs in his phone he will call the professor again. Professor Djuric wants to organize his time well and he needs a good estimation for how much time Dragance will need before he can call him again.
Limitations:
*Numbers N and M are not bigger then 200
* K is not bigger then 500
*The number of spots with outlets is not bigger then 1000
*Char 'F' is located in exactly one input database
*The park is made so Dragance can always get to some of the outlets. There are no outlets in the part with the fountain.
Note:
If just one number MIN or MAX is correct, you will get 50% of the points for that example.
input:
5 5
3
x..xF
.x...
T..x.
x.T..
...T.
output:
2 5
Explanation:
After three minutes of conversation, Dragance will be able to get closer to some of the spots with outlets and then it will only take two minutes to get to them. It's possible for Dragance to stay at the fountain during the conversation, so he would then need five minutes to get to the nearest outlets.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.