But the input contains lines that have less than c characters. Got many WAs debugging a correct program because of that.The first line of each case contains two integers r and c (1 <= r, c <= 20), which are the number of rows and columns of the map respectively. The next r lines, each with c characters, give the map itself.
EDIT: This remark was false. Read on to know why.