#C11347. Find the CODE Pattern in Grids

    ID: 40653 Type: Default 1000ms 256MiB

Find the CODE Pattern in Grids

Find the CODE Pattern in Grids

You are given one or more rectangular grids containing uppercase letters. In each grid, your task is to determine whether the pattern "CODE" appears in the grid. The pattern can appear in any of the eight possible directions: horizontally, vertically, or diagonally.

Each test case starts with two integers M and N representing the number of rows and columns, respectively. This is followed by M lines, each containing N uppercase letters (separated by spaces). Input terminates with a test case where both M and N are 0, which should not be processed.

For each grid, if the word "CODE" is found in any allowed direction, output FOUND; otherwise, output NOT FOUND. When there are multiple test cases, the answers should be output in the same order as the input, each on a separate line.

inputFormat

The input consists of several test cases. Each test case begins with a line containing two integers M and N (the number of rows and columns). This is followed by M lines, each containing N space-separated uppercase letters. The input ends with a line containing "0 0" which should not be processed.

outputFormat

For each test case, output a line containing either FOUND or NOT FOUND indicating whether the pattern "CODE" appears in the grid in any direction.

## sample
4 5
C X D E X
O D X C C
D X D G O
E O C D E
0 0
FOUND