To the end and to the right

You are walking down a street when, suddenly, you have a physiological
urgency. You enter into a bar, and ask for the toilet. “To the end and
to the right”, they tell you. Will you find the way?

Write a program that reads several maps of bars, and for each one tells
if there is any path that first goes from the bottom to the very top,
and then to the very right.

Input

Input consists of several cases. Every case begins with two natural
numbers r ≥ 2 and c ≥ 2, followed by r rows with c characters each. A
‘.’ indicates a position which you can pass by. An ‘X’ indicates a
position which you cannot pass by. The upper-right position always has a
‘.’. The rest of positions of the right column always have an ‘X’. A
special case with r = c = 0 marks the end of input.

Output

Print a line for each bar: if there is any way to the top and then to
the right, print “bufff”; otherwise, print “ui ui ui”.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:34:44.980Z

© Jutge.org, 2006–2026.
https://jutge.org
