You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At the far side of the room lies a door locked with evil magical forces. The following inscriptions are written on the door: The cleaning of all evil will awaken the door! 

Being a very senior adventurer, you immediately realize what this means. You notice that every single cell in the grid are initially evil. You should purify all of these cells.

The only method of tile purification known to you is by casting the "Purification" spell. You cast this spell on a single tile — then, all cells that are located in the same row and all cells that are located in the same column as the selected tile become purified (including the selected tile)! It is allowed to purify a cell more than once.

You would like to purify all n × n cells while minimizing the number of times you cast the "Purification" spell. This sounds very easy, but you just noticed that some tiles are particularly more evil than the other tiles. You cannot cast the "Purification" spell on those particularly more evil tiles, not even after they have been purified. They can still be purified if a cell sharing the same row or the same column gets selected by the "Purification" spell.

Please find some way to purify all the cells with the minimum number of spells cast. Print -1 if there is no such way.


-----Input-----

The first line will contain a single integer n (1 ≤ n ≤ 100). Then, n lines follows, each contains n characters. The j-th character in the i-th row represents the cell located at row i and column j. It will be the character 'E' if it is a particularly more evil cell, and '.' otherwise.


-----Output-----

If there exists no way to purify all the cells, output -1. Otherwise, if your solution casts x "Purification" spells (where x is the minimum possible number of spells), output x lines. Each line should consist of two integers denoting the row and column numbers of the cell on which you should cast the "Purification" spell.


-----Examples-----
Input
3
.E.
E.E
.E.

Output
1 1
2 2
3 3

Input
3
EEE
E..
E.E

Output
-1

Input
5
EE.EE
E.EE.
E...E
.EE.E
EE.EE

Output
3 3
1 3
2 2
4 4
5 3


-----Note-----

The first example is illustrated as follows. Purple tiles are evil tiles that have not yet been purified. Red tile is the tile on which "Purification" is cast. Yellow tiles are the tiles being purified as a result of the current "Purification" spell. Green tiles are tiles that have been purified previously.  [Image] 

In the second example, it is impossible to purify the cell located at row 1 and column 1.

For the third example: [Image]

Difficulty: competition

Starter code:

Solutions:
n = int(input())
d = []
for i in range(n):
    d.append(input())

for i in range(n):
    if d[i].count('E') == n:
        break
else:
    for i in range(n):
        print(i+1, d[i].index('.')+1)
    return

for i in range(n):
    res = 0
    for j in range(n):
        if d[j][i] == 'E':
            res += 1
    if res == n:
        break
else:
    for i in range(n):
        for j in range(n):
            if d[j][i] == '.':
                print(j+1, i+1)
                break
    return
print(-1)

n = int(input())

vr = [set() for x in range(0, n)]
vc = [set() for x in range(0, n)]
r = set(range(0, n))
c = set(range(0, n))

for i in range(0, n):
    s = input()
    for j in range(0, n):
        if s[j] == '.':
            vr[i].add(j)
            vc[j].add(i)
            r.discard(i)
            c.discard(j)

if len(r) == 0:
    for i in range(0, n):
        print(i+1, vr[i].pop()+1)
elif len(c) == 0:
    for j in range(0, n):
        print(vc[j].pop()+1, j+1)
else:
    print(-1)


n=int(input())

rows=[]
evils=0
for i in range(n):
    rows.append(input())
##    evils+=rows[-1].count('E')

columns=[]
for i in range(n):
    L=[]
    for j in range(n):
        L.append(rows[j][i])
    columns.append(L)
can=True
for i in range(n):
    if(not can):
        break
    for j in range(n):
        if(rows[i][j]=='.'):
            continue
        r='.' not in rows[i]
        c='.' not in columns[j]
        if(r and c):
            can=False
            break

if(not can):
    print(-1)
else:
    used='rows'
    for i in range(n):
        if(rows[i].count('E')==n):
            used='columns'
            break
        elif(columns[i].count('E')==n):
            used='rows'
            break
    if(used=='rows'):
        for i in range(n):
            x=rows[i].index('.')
            print(i+1,end=" "+str(x+1)+'\n')
    else:
        for i in range(n):
            x=columns[i].index('.')
            print(x+1,end=" "+str(i+1)+'\n')
            


a = []
n = int(input())
for i in range(0, n):
    a.append(input())


l = [0 for i in range(0, n)]
c = [0 for i in range(0, n)]
    

for i in range(0, n):
    for j in range(0, n):
        if a[i][j] == 'E':
            l[i] += 1
            c[j] += 1

if n in l and n in c:
    print('-1')
    return

if n in l:              #am o linie plina de E-uri
    for j in range(0, n):
        i = 0
        while a[i][j] != '.': i += 1
        print("%i %i" % (i+1, j+1))

else:
    for i in range(0, n):
        j = 0
        while a[i][j] != '.': j += 1
        print("%i %i" % (i+1, j+1))
            


n = int(input())
t = [input() for i in range(n)]
e = 'E' * n
if e in t:
    t = list(''.join(i) for i in zip(*t))
    if e in t: print('-1')
    else:
        p = [str(c.find('.') + 1) + ' ' + str(i) for i, c in enumerate(t, 1)]
        print('\n'.join(p))
else:
    p = [str(i) + ' ' + str(c.find('.') + 1) for i, c in enumerate(t, 1)]
    print('\n'.join(p))

from sys import stdin

__author__ = 'artyom'


def solve(x):
  a = []
  for s in x:
    dot_pos = s.find('.')
    if dot_pos < 0:
      return None
    a.append(dot_pos + 1)
  return a


def rotate(x, n):
  y = []
  for i in range(n):
    y.append([])
    for j in range(n):
      y[i].append(x[j][i])
  return map(lambda b: ''.join(b), y)


n = int(stdin.readline().strip())
x = []
for _ in range(n):
  x.append(stdin.readline().strip())

a = solve(x)
if a:
  for i in range(n):
    print(i + 1, a[i])
else:
  a = solve(rotate(x, n))
  if a:
    for i in range(n):
      print(a[i], i + 1)
  else:
    print(-1)

def main():
    n = int(input())
    l = [input() for _ in range(n)]
    res = []
    for y, s in enumerate(l):
        for x, c in enumerate(s):
            if c == '.':
                res.append((x, y))
                break
    if len(res) < n:
        res = []
        for x in range(n):
            for y in range(n):
                if l[y][x] == '.':
                    res.append((x, y))
                    break
        if len(res) < n:
            print(-1)
            return
    for x, y in res:
        print(y + 1, x + 1)


def __starting_point():
    main()

__starting_point()



class Solver(object):
    def read_input(self):
        n = int(input())
        grid = []
        for i in range(n):
            l = list(input())
            grid.append(l)

        self.n = n
        self.grid = grid

    def solve_line(self):
        pos = []
        for i in range(self.n):
            res = False
            for j in range(self.n):
                if self.grid[i][j]==".":
                    res = True
                    pos.append((i,j))

                if res==True:
                    break
            if res==True:
                continue
            else:
                pos = -1
                break
        self.pos = pos
        return pos

    def solve_column(self):
        pos = []
        for j in range(self.n):
            res = False
            for i in range(self.n):
                if self.grid[i][j]==".":
                    res = True
                    pos.append((i,j))

                if res==True:
                    break
            if res==True:
                continue
            else:
                pos = -1
                break
        self.pos = pos
        return pos

    def print_solution(self):
        for i, j in self.pos:
            print(i+1, j+1)
    def solve(self):
        lines = self.solve_line()
        if lines != -1:
            self.print_solution()

        else:
            cols = self.solve_column()
            if cols == -1:
                print(-1)
            else:
                self.print_solution()


S = Solver()
S.read_input()
S.solve()



n = int( input() )

pl = [0] * 100
p = [ [] for i in range(100) ]

s = [ str() for i in range(100) ]

cp = [0] * 100
rp = [0] * 100

X = 0
Y = 0

for i in range(n):
    s[i] = str( input() )
    f = 0
    for j in range(len(s[i])):
          if s[i][j]=='.':
            f = 1
            break
    if f == 0:
      X = 1


for i in range(n):
    f = 0
    for j in range(n):
        if s[j][i]=='.':
            f = 1
            break
    if f == 0:
      Y = 1

#print(X,Y)

if X==1 and Y==1:
    print("-1")
else:
    if X == 0:
        for i in range(n):
            for j in range(n):
                if s[i][j]=='.':
                    print(i+1,j+1)
                    break
    else:
        for i in range(n):
            for j in range(n):
                if s[j][i]=='.':
                    print(j+1,i+1)
                    break


n = int(input())
g = []
r = [0]*n
c = [0]*n
for i in range(n):
    g.append(list(input()))
    x = [a for a in range(n) if g[i][a] == '.']
    if len(x) > 0: r[i] = 1
    for j in x: c[j] = 1
if sum(r) == n:
    for i in range(n):
        for j in range(n):
            if g[i][j] == '.':
                print('%i %i' % (i+1,j+1))
                break
elif sum(c) == n:
    for i in range(n):
        for j in range(n):
            if g[j][i] == '.':
                print('%i %i' % (j+1,i+1))
                break
else:
    print(-1)

n = int(input())

a = []

for i in range(n):

    a.append(input())

if 'E' * n in a and ('E',) * n in list(zip(*a)):

    print(-1)

elif 'E' * n in a:

    for j, s in enumerate([''.join(x) for x in zip(*a)]):

        for i, c in enumerate(s):

            if c == '.':

                print(i + 1, j + 1)

                break

else:

    for i, s in enumerate(a):

        for j, c in enumerate(s):

            if c == '.':

                print(i + 1, j + 1)

                break



n = int(input())
s = [''] * n
for i in range(n):
    s[i] = input()
row, col = 0, 0
for i in range(n):
    for j in range(n):
        if s[i][j] == '.':
            break
    else:
        row = 1
        break
for i in range(n):
    for j in range(n):
        if s[j][i] == '.':
            break
    else:
        col = 1
        break
if row == col == 1:
    print(-1)
    return
if row == 0:
    for i in range(n):
        for j in range(n):
            if s[i][j] == '.':
                print(i+1, j+1)
                break
else:
    for i in range(n):
        for j in range(n):
            if s[j][i] == '.':
                print(j+1, i+1)
                break


n=int(input())
it=[input() for i in range(n)]
res,k=[],0
for i,x in enumerate(it):
    k=0
    for j,y in enumerate(x):
        if y=='.':
            res.append([i+1,j+1])
            k=1;break
    if k==0:break
if k==1:
    for i,x in enumerate(res):print(*x)
else:
    res,k=[],0
    for i,x in enumerate(it):
        k=0
        for j,y in enumerate(x):
            y=it[j][i]
            if y=='.':
                res.append([j+1,i+1])
                k=1;break
        if k==0:break
    if k==1:
        for i,x in enumerate(res):print(*x)
    else:print(-1)

n = int(input())
l = []
for _ in range(n):
    l.append([x for x in input()])

results = []
thing = True
for i in range(n):
    hit = False
    for j in range(n):
        if l[i][j] != "E":
            results.append(f"{i + 1} {j + 1}")
            hit = True
            break
    if not hit:
        thing = False
        break
if not thing:
    results = []
    thing = True
    for j in range(n):
        hit = False
        for i in range(n):
            if l[i][j] != "E":
                results.append(f"{i + 1} {j + 1}")
                hit = True
                break
        if not hit:
            thing = False
            break

if thing:
    for r in results:
        print(r)
else:
    print(-1)


def transpose(x):
    return [list(row) for row in zip(*x)]

def canpurify(x):
    for i in x:
        founddot = False
        for j in i:
            if j == '.':
                founddot = True
                break
        if not founddot:
            return False
    return True

field = []
n = int(input())

def purify(x, transposed):
    for i in range(len(x)):
        for j in range(len(x)):
            if x[i][j] == '.':
                if not transposed:
                    print(i+1, j+1)
                else:
                    print(j+1, i+1)
                break

for _ in range(n):
    field.append(input())
t = False
if not canpurify(field):
    field = transpose(field)
    t = True

if canpurify(field):
    purify(field, t)
else:
    print(-1)



a = []
n = int(input())
for i in range(0, n):
    a.append(input())

l = [0 for i in range(0, n)]
c = [0 for i in range(0, n)]

for i in range(0, n):
    for j in range(0, n):
        if a[i][j] == 'E':
            l[i] += 1
            c[j] += 1

if n in l and n in c:
    print('-1')
    return

if n in l:  
    for j in range(0, n):
        i = 0
        while a[i][j] != '.': i += 1
        print("%i %i" % (i + 1, j + 1))

else:
    for i in range(0, n):
        j = 0
        while a[i][j] != '.': j += 1
        print("%i %i" % (i + 1, j + 1))


n=int(input())
it=[input() for i in range(n)]
res,k=[],0
for i,x in enumerate(it):
    k=0
    for j,y in enumerate(x):
        if y=='.':
            res.append([i+1,j+1])
            k=1;break
    if k==0:break
if k==1:
    for i,x in enumerate(res):print(*x)
else:
    res,k=[],0
    for i,x in enumerate(it):
        k=0
        for j,y in enumerate(x):
            y=it[j][i]
            if y=='.':
                res.append([j+1,i+1])
                k=1;break
        if k==0:break
    if k==1:
        for i,x in enumerate(res):print(*x)
    else:print(-1)

n = int(input())
 
vr = [set() for x in range(0, n)]
vc = [set() for x in range(0, n)]
r = set(range(0, n))
c = set(range(0, n))
 
for i in range(0, n):
    s = input()
    for j in range(0, n):
        if s[j] == '.':
            vr[i].add(j)
            vc[j].add(i)
            r.discard(i)
            c.discard(j)
 
if len(r) == 0:
    for i in range(0, n):
        print(i+1, vr[i].pop()+1)
elif len(c) == 0:
    for j in range(0, n):
        print(vc[j].pop()+1, j+1)
else:
    print(-1)

n = int(input())
 
vr = [set() for x in range(0, n)]
vc = [set() for x in range(0, n)]
r = set(range(0, n))
c = set(range(0, n))
 
for i in range(0, n):
    s = input()
    for j in range(0, n):
        if s[j] == '.':
            vr[i].add(j)
            vc[j].add(i)
            r.discard(i)
            c.discard(j)
 
if len(r) == 0:
    for i in range(0, n):
        print(i+1, vr[i].pop()+1)
elif len(c) == 0:
    for j in range(0, n):
        print(vc[j].pop()+1, j+1)
else:
    print(-1)



n=int(input())
s=[]
for i in range(n):
    s.append(input())
r,cl=0,0
for i in range(n):
    c=0
    for j in range(n):
        if s[i][j]=='E':
            c=c+1
    r=max(r,c)
for i in range(n):
    c=0
    for j in range(n):
        if s[j][i]=='E':
            c=c+1
    cl=max(cl,c)
if r==n and cl==n:
    print(-1)
else:
    ans=[]
    if r!=n:
        for i in range(n):
            for j in range(n):
                if s[i][j]=='.':
                    ans.append([i+1,j+1])
                    break
    else:
        for i in range(n):
            for j in range(n):
                if s[j][i]=='.':
                    ans.append([j+1,i+1])
                    break
    for i in range(n):
        print(ans[i][0],ans[i][1])