Under construction

Still being built. Things may change

Oooh I See

Interview

Time limit1sMemory limit2048 MB

Summary
Given a grid of O and 0 characters, find every 0 whose eight neighbors are all O, then print its position, the count, or Oh no!.
Level

Easy2 of 10

Topics
Matrix, Brute force
Solved
No attempts yet

Problem

Captain O'Capten hid some treasure and drew a map marking where it is buried. Instead of marking the spot with an X, he hid the location in a grid of uppercase O letters and 0 digits. The treasure is at a 0 character whose eight neighbors, above, below, left, right, and the four diagonals, are all O characters. Captain O'Capten wants to find the treasure, but his map is hard to read (no surprise there).

Input

The first line contains two integers rr and cc (1≤r,c≤501 \leq r, c \leq 50), the number of rows and columns on the map. The next rr lines each contain cc characters, each either O or 0. Rows are numbered 1 to rr from top to bottom, and columns are numbered 1 to cc from left to right.

Output

If no 0 character is surrounded on all sides by 8 O characters, print Oh no! on one line. If more than one such 0 exists, print Oh no! N locations, with N replaced by the count. If exactly one exists, print its row number and column number on one line, separated by a space.

Examples3

  1. Example 1

    Input
    3 6
    OO0OOO
    00OO0O
    0O0OOO
    
    Expected output
    2 5
    
  2. Example 2

    Input
    5 3
    OOO
    O0O
    OOO
    O0O
    OOO
    
    Expected output
    Oh no! 2 locations
    
  3. Example 3

    Input
    4 4
    OOO0
    0O0O
    OOO0
    0O0O
    
    Expected output
    Oh no!