Skip to main content

~/algor $ cat contests/round-6/E

E. k in a row

Problem E ICPC rules 1000 ms 64 MB

Each cell of an board holds X, O or . (an empty cell). If equal symbols stand in a row (with no other cell between them) horizontally, vertically or along a diagonal of either direction, the owner of that symbol wins. Print the winner's symbol; if there is no winner, print -.

A 3 × 3 board: three X stand in a row on the main diagonal

Input

The first line contains two positive integers: and . Each of the next lines contains a string of characters (X, O or .).

Output

One character: X, O or -.

Note


the two symbols never win at the same time

Examples

Input #1
3 3
XOX
OXO
O.X
Output #1
X
Input #2
4 3
XO..
.OX.
X...
.O.X
Output #2
-

Sign in to submit a solution

Signing up is free and takes a minute.