After years of developement, Nayaab has finally created the world's first fully automatic facial machine! The only problem being she forgot to program it to check whether or not it actually sees a face.
While the device does have a camera, Nayaab informs you that the camera is very limited. It can only caputure a by grainy image. Because of this, faces should be rejected if one of their features (eye or mouth) has an erroneous adjacent black pixel.
She then proceeds to hand you the following schematic that describes a face:
Where the eyes are always pixel in height and width, and the mouth is always pixel in height.
Luckily you only have to check for the two eyes and a straight mouth for faces and you can assume that faces are always vertical.
Can you write a program to detect faces for Nayaab?
Input Specification
The first line consists of two integers, , , the width and height of the image respectivly.
The next lines each contain characters. Each character will either be .
, representing a white pixel, or #
representing a black pixel in the image.
Output Specification
Output OK
if only one face is found.
Otherwise output ABORT
on the first line and on a second line output the number of faces detected.
Sample Input 1
10 10
..........
..........
...######.
..########
.##..#.###
....#...##
...#.....#
..#.......
######....
#####.....
Sample Output 1
ABORT
0
Sample Input 2
10 10
..........
.#........
..#...#...
..........
.######...
........#.
..........
....#.....
....#.....
..........
Sample Output 2
OK
Comments