Under construction

Still being built. Things may change

Special School Escape

Interview

Time limit1sMemory limit1024 MB

Summary
Given N teacher patrol strings over M periods, find the earliest period when no teacher patrols, or report ESCAPE FAILED if none exists.
Level

Easy2 of 10

Topics
Implementation, String
Solved
No attempts yet

Problem

Students at NLCS Jeju are tired of classes and want to escape from school. Escaping during class hours is difficult.

Class hours at NLCS Jeju run from period 11 to period MM. There are NN teachers at NLCS Jeju, and each teacher patrols during class hours between period 11 and period MM according to a fixed schedule. To avoid being caught, students must escape when no teacher is patrolling. If a patrolling teacher is present at the moment students try to escape, they are caught without fail.

Given the patrol schedule of each teacher, determine whether the students can escape from school, and if they can, find the earliest time at which they can escape.

Input

The first line contains the number of teachers NN and the number of class periods MM, separated by a space.

Each of the next NN lines contains a string of length MM made of O and X. If the ii-th character of the (j+1)(j+1)-th line is O, the jj-th teacher patrols at time ii. If it is X, the jj-th teacher does not patrol at time ii.

Output

Print the period of the earliest moment at which the students can escape without being caught. If the students cannot escape without being caught, print ESCAPE FAILED.

Constraints

1≤N,M≤1001 \le N,M \le 100

Examples3

  1. Example 1

    Input
    5 5
    OXXOO
    XXXOX
    OOXXX
    OXXOO
    XOXXO
    
    Expected output
    3
    
  2. Example 2

    Input
    5 5
    OXXXX
    XOXXX
    XXOXX
    XXXOX
    XXXXO
    
    Expected output
    ESCAPE FAILED
    
  3. Example 3

    Input
    7 5
    OOXXO
    OXXOO
    XOXXX
    XOOOX
    OOOXX
    OXOOO
    XOOXO
    
    Expected output
    ESCAPE FAILED