Hidden words

Write a program that reads a sequence of rectangular grids, and for each one prints where starts and where ends the single word that contains. If a grid does not have any word, the program must indicate it.

Input

Input consists of a series of grid descriptions separated by an empty line. Each grid starts with two natural numbers strictly positive: the number of rows nn and the number of columns mm. After, nn rows with mm characters (any space) for each one. Each grid contains, at most, a word, horizontally, vertically, or in the two diagonal directions. In this problem, a word is a non empty sequence of uppercase letters.

Output

For each grid, if contains any word, print where starts and where ends (the vertical words are from the top to the bottom; the other words are from the left to the right); otherwise, print that the grid does not contain any word. Follow the format of the instance.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:57:03.918Z

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