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]

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Constructive algorithms


Solutions:
n = int(input())
a = []
for i in range(n):
	a.append(input())
if 'E' * n in a and ('E',) * n in zip(*a):
	print(-1)
elif 'E' * n in a:
	for (j, s) in enumerate(map(lambda x: ''.join(x), 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


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)


f = lambda : input()
n = int(f())
m = []
for i in range(n):
	m.append(input())
fr = []
fc = []
fct = [False] * n
for i in range(n):
	for j in range(n):
		if m[i][j] == '.':
			fr.append((i + 1, j + 1))
			break
for i in range(n):
	if len(fc) < n:
		for j in range(n):
			if len(fc) > n - 1:
				break
			if m[i][j] == '.':
				if fct[j] == False:
					fct[j] = True
					fc.append((i + 1, j + 1))
if len(fr) == n:
	for i in range(n):
		print(fr[i][0], fr[i][1])
elif len(fc) == n:
	for i in range(n):
		print(fc[i][0], fc[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()


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())
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())
grid = [input() for line in range(n)]
total = sum([ln.count('.') for ln in grid])
rowsWSpcN = len([True for ln in grid if '.' in ln])
colsWSpcN = len([True for col in range(n) if '.' in [ln[col] for ln in grid]])
rowsWSpc = [ln.count('.') for ln in grid]
colsWSpc = [[ln[col] for ln in grid].count('.') for col in range(n)]
used = 0
if 0 in rowsWSpc and 0 in colsWSpc:
	print(-1)
elif 0 not in rowsWSpc:
	for row in range(n):
		print(row + 1, grid[row].index('.') + 1)
else:
	for col in range(n):
		print([grid[row][col] for row in range(n)].index('.') + 1, col + 1)


n = int(input())
maze = [input().strip() for _ in range(n)]

def go(x):
	global maze
	maze = list(zip(*maze))
	check = True
	for i in range(n):
		if '.' not in maze[i]:
			check = False
	if check:
		for i in range(n):
			for j in range(n):
				if maze[i][j] == '.':
					print(i + 1, j + 1) if x else print(j + 1, i + 1)
					break
	return check
if not go(0) and (not go(1)):
	print(-1)


n = int(input())
arr = []
for _ in range(n):
	arr.append(list(input()))
ans = []
for row in range(n):
	for col in range(n):
		if arr[row][col] == '.':
			ans.append((row + 1, col + 1))
rows = []
cols = []
for i in ans:
	if i[0] not in rows:
		rows.append(i[0])
	if i[1] not in cols:
		cols.append(i[1])
if len(rows) != n and len(cols) != n:
	print(-1)
elif len(rows) == n:
	rows = []
	for i in ans:
		if i[0] not in rows:
			print(i[0], i[1])
			rows.append(i[0])
else:
	cols = []
	for i in ans:
		if i[1] not in cols:
			print(i[0], i[1])
			cols.append(i[1])


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())
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])


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())
linhaCheia = 'E' * n
linhas = [input() for k in range(n)]
if not linhaCheia in linhas:
	for i in range(n):
		lessEvil = linhas[i].find('.')
		print(i + 1, lessEvil + 1)
else:
	colunas = [''.join(k) for k in list(zip(*linhas))]
	if linhaCheia in colunas:
		print(-1)
	else:
		for i in range(n):
			lessEvil = colunas[i].find('.')
			print(lessEvil + 1, i + 1)


n = int(input())
arr = []
flag = True
for _ in range(n):
	s = input()
	if s == 'E' * n:
		flag = False
	arr.append(s)
if flag:
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '.':
				print(i + 1, j + 1)
				break
else:
	sf = True
	for i in range(n):
		temp = ''
		for j in range(n):
			temp += arr[j][i]
		if temp == 'E' * n:
			sf = False
			break
	if sf == False:
		print('-1')
	else:
		for i in range(n):
			for j in range(n):
				if arr[j][i] == '.':
					print(j + 1, i + 1)
					break


import sys
n = int(input())
A = [input().strip() for _ in range(n)]
if all(('.' in a for a in A)):
	for i in range(n):
		j = A[i].find('.')
		print(i + 1, j + 1)
	sys.exit()
A = [''.join(s) for s in zip(*A)]
if all(('.' in a for a in A)):
	for i in range(n):
		j = A[i].find('.')
		print(j + 1, i + 1)
	sys.exit()
print('-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)


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)


def f(g, n):
	col = [0] * n
	row = [0] * n
	colcnt = [0] * n
	rowcnt = [0] * n
	for r in range(n):
		for c in range(n):
			if g[r][c] == '.':
				rowcnt[r] += 1
				colcnt[c] += 1
	ans1 = []
	for i in range(n):
		if colcnt[i] == 0 and rowcnt[i] == 0:
			return -1
	for r in range(n):
		for c in range(n):
			if g[r][c] == '.' and row[r] == 0:
				ans1.append((r + 1, c + 1))
				row[r] = 1
	ans2 = []
	for r in range(n):
		for c in range(n):
			if g[c][r] == '.' and col[r] == 0:
				ans2.append((c + 1, r + 1))
				col[r] = 1
	if row.count(0) and col.count(0):
		return -1
	if len(ans1) == n:
		ans = ans1
	else:
		ans = ans2
	for i in ans:
		print(*i)
	return ''
n = int(input())
g = []
for i in range(n):
	g.append(list(input()))
print(f(g, n))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
row = defaultdict(list)
col = defaultdict(list)
points = []
for i in range(n):
	s = input()
	for j in range(n):
		if s[j] == '.':
			row[i].append((i + 1, j + 1))
			col[j].append((i + 1, j + 1))
			points.append((i, j))
ok = [False, False]
for i in range(n):
	if len(row[i]) == 0:
		ok[0] = True
	if len(col[i]) == 0:
		ok[1] = True
if ok[0] and ok[1]:
	print(-1)
	exit()
if ok[1]:
	for i in range(n):
		print(*row[i][0])
else:
	for i in range(n):
		print(*col[i][0])


n = int(input())
a = [input() for i in range(n)]

def checkRows():
	for str in a:
		if '.' not in str:
			return False
	return True

def solveRows():
	i = 1
	for str in a:
		print(i, str.find('.') + 1)
		i += 1

def checkColumns():
	for j in range(n):
		str = ''.join((a[i][j] for i in range(n)))
		if '.' not in str:
			return False
	return True

def solveColumns():
	i = 1
	for j in range(n):
		str = ''.join((a[i][j] for i in range(n)))
		print(str.find('.') + 1, i)
		i += 1
if checkRows():
	solveRows()
elif checkColumns():
	solveColumns()
else:
	print('-1')


import sys
fin = sys.stdin
n = int(fin.readline())
a = [fin.readline().strip() for i in range(n)]

def CanSolveByColumns():
	for j in range(n):
		col = ''.join((a[i][j] for i in range(n)))
		if col.find('.') == -1:
			return False
	return True

def CanSolveByRows():
	for i in range(n):
		row = a[i]
		if row.find('.') == -1:
			return False
	return True

def SolveByColumns():
	for j in range(n):
		col = ''.join((a[i][j] for i in range(n)))
		print(col.find('.') + 1, j + 1)

def SolveByRows():
	for i in range(n):
		row = a[i]
		print(i + 1, row.find('.') + 1)
if CanSolveByColumns():
	SolveByColumns()
elif CanSolveByRows():
	SolveByRows()
else:
	print(-1)


import traceback
import math
from collections import defaultdict
from functools import lru_cache

def main():
	N = int(input())
	grid = []
	for _ in range(N):
		s = input()
		grid.append(s)
	if all(('.' in [grid[i][j] for j in range(N)] for i in range(N))):
		for i in range(N):
			for j in range(N):
				if grid[i][j] == '.':
					print(i + 1, j + 1)
					break
	elif all(('.' in [grid[i][j] for i in range(N)] for j in range(N))):
		for j in range(N):
			for i in range(N):
				if grid[i][j] == '.':
					print(i + 1, j + 1)
					break
	else:
		print(-1)
try:
	ans = main()
except Exception as e:
	traceback.print_exc()


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))


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
l = []
an = []
for i in range(n):
	x = input().strip()
	l.append(x)
	if '.' in x:
		an.append([i + 1, x.index('.') + 1])
if len(an) == n:
	for i in an:
		print(*i)
else:
	an = []
	for i in range(n):
		for j in range(n):
			if l[j][i] == '.':
				an.append([j + 1, i + 1])
				break
	if len(an) == n:
		for i in an:
			print(*i)
	else:
		print(-1)


n = int(input())
rows = []
evils = 0
for i in range(n):
	rows.append(input())
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')


n = int(input())
i = 0
grid = []
while i < n:
	grid.append(input())
	i += 1
row = [False] * n
col = [False] * n
i = 0
while i < n:
	j = 0
	while j < n:
		if grid[i][j] == '.':
			col[j] = True
			row[i] = True
		j += 1
	i += 1
vert = sum(col) == n
horiz = sum(row) == n
if not vert and (not horiz):
	print('-1')
	exit(0)
i = 0
while i < n:
	j = 0
	while j < n:
		if grid[i][j] == '.':
			if vert:
				if col[j]:
					print(str(i + 1) + ' ' + str(j + 1))
					col[j] = False
			elif row[i]:
				print(str(i + 1) + ' ' + str(j + 1))
				break
		j += 1
	i += 1


def checker(r, c):
	flag = True
	if -1 in r:
		flag = False
	if flag:
		for k in range(n):
			print(k + 1, ' ', r[k] + 1)
		return
	flag = True
	if -1 in c:
		flag = False
	if flag:
		for l in range(n):
			print(c[l] + 1, ' ', l + 1)
		return
	print(-1)
n = int(input())
row = [-1] * n
col = [-1] * n
for i in range(n):
	val = input()
	for j in range(n):
		if val[j] == '.':
			row[i] = j
			col[j] = i
checker(row, col)


def check_row_wise(board):
	for row in board:
		if '.' not in row:
			return False
	return True

def check_col_wise(board):
	n = len(board)
	for i in range(n):
		flag = False
		for j in range(n):
			if board[j][i] == '.':
				flag = True
		if not flag:
			return False
	return True
n = int(input())
board = []
for _ in range(n):
	x = list(input())
	board.append(x)
row_check = check_row_wise(board)
col_check = check_col_wise(board)
if not row_check and (not col_check):
	print(-1)
elif row_check:
	for (i, row) in enumerate(board):
		x = row.index('.')
		print(i + 1, x + 1)
else:
	for i in range(n):
		for j in range(n):
			if board[j][i] == '.':
				print(j + 1, i + 1)
				break


n = int(input())
graph = []
col = [0] * n
row = [0] * n
for i in range(n):
	graph.append(input())
for i in range(n):
	for j in range(n):
		if graph[i][j] == '.':
			col[j] = 1
			row[i] = 1
colHasDot = False
rowHasDot = False
if 0 not in col:
	colHasDot = True
if 0 not in row:
	rowHasDot = True
if not colHasDot and (not rowHasDot):
	print('-1')
	exit(0)
for i in range(n):
	j = 0
	for j in range(n):
		if graph[i][j] == '.':
			if colHasDot:
				if col[j]:
					print(i + 1, j + 1)
					col[j] = False
			elif row[i]:
				print(i + 1, j + 1)
				break


from collections import *

def get_str_col(arr, i):
	return ''.join([row[i] for row in arr])

def check():
	(r, c) = (0, 0)
	for i in range(n):
		if tile[i].count('E') == n:
			r = 1
			break
	for i in range(n):
		if get_str_col(tile, i).count('E') == n:
			c = 1
			break
	if r == c == 1:
		exit(print(-1))
	return (r, c)
n = int(input())
(tile, extra, ans, row, col) = ([input() for i in range(n)], 0, [], defaultdict(int, {i: n for i in range(n)}), defaultdict(int, {i: n for i in range(n)}))
(r, c) = check()
if r == c == 0 or r == 1:
	for i in range(n):
		for j in range(n):
			if tile[i][j] == '.':
				if col[j]:
					extra += 1
					ans.append([i + 1, j + 1])
					col[j] = 0
else:
	for i in range(n):
		for j in range(n):
			if tile[i][j] == '.':
				if row[i]:
					extra += 1
					ans.append([i + 1, j + 1])
					row[i] = 0
for i in range(n):
	print(*ans[i])


n = int(input())
c = [list(input()) for _ in range(n)]
r = set()
s = set()
rows = set()
cols = set()
for i in range(n):
	for j in range(n):
		if c[i][j] == '.' and i not in rows:
			r.add((i + 1, j + 1))
			rows.add(i)
			break
for i in range(n):
	for j in range(n):
		if c[j][i] == '.' and i not in cols:
			s.add((j + 1, i + 1))
			cols.add(i)
			break
if not set(range(n)) - rows:
	print('\n'.join(map(lambda x: str(x[0]) + ' ' + str(x[1]), r)))
elif not set(range(n)) - cols:
	print('\n'.join(map(lambda x: str(x[0]) + ' ' + str(x[1]), s)))
else:
	print(-1)


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
for i in range(n):
	s[i] = str(input())
	for j in range(len(s[i])):
		if s[i][j] == '.':
			rp[i] += 1
			cp[j] += 1
tag1 = 0
for i in range(n):
	if cp[i] == 0:
		tag1 = 1
		break
if tag1 == 0:
	for i in range(n):
		for j in range(n):
			if s[i][j] == '.':
				p[i].append(j)
				pl[i] += 1
	for i in range(n):
		for j in range(pl[i]):
			cp[p[i][j]] -= 1
			if cp[p[i][j]] == 0:
				print(i + 1, p[i][j] + 1)
	exit()
for i in range(n):
	if rp[i] == 0:
		print('-1')
		exit()
for i in range(n):
	for j in range(n):
		if s[j][i] == '.':
			p[i].append(j)
			pl[i] += 1
for i in range(n):
	for j in range(pl[i]):
		rp[p[i][j]] -= 1
		if rp[p[i][j]] == 0:
			print(p[i][j] + 1, i + 1)


import sys, math as mt
import heapq as hp
import collections as cc
import math as mt
import itertools as it
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
ar = []
tf = 1
ans = []
for i in range(n):
	x = input().strip()
	if '.' not in x:
		tf = 0
	else:
		temp = x.index('.')
		ans.append([i + 1, temp + 1])
	ar.append(x)
if not tf:
	tf = 1
	ans = []
	k = 0
	for i in zip(*ar):
		k += 1
		if '.' not in i:
			tf = 0
			break
		temp = i.index('.')
		ans.append([temp + 1, k])
	if not tf:
		print(-1)
	else:
		for i in ans:
			print(*i)
else:
	for i in ans:
		print(*i)


n = int(input())
mat = []
for i in range(n):
	l = list(input())
	mat.append(l)
col = row = 0
for i in range(n):
	if mat[i].count('E') == n:
		col = 1
		break
for i in range(n):
	c = 0
	for j in range(n):
		if mat[j][i] == 'E':
			c += 1
	if c == n:
		row += 1
		break
if row == 1 and col == 1:
	print(-1)
elif row == 1:
	for i in range(n):
		for j in range(n):
			if mat[i][j] == '.':
				print(i + 1, j + 1)
				break
else:
	for i in range(n):
		for j in range(n):
			if mat[j][i] == '.':
				print(j + 1, i + 1)
				break


n = int(input())
inp = [input() for i in range(n)]
A = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
	for j in range(n):
		if inp[i][j] == 'E':
			A[i][j] = 1
k = 0
for i in A:
	if sum(i) == n:
		k += 1
c = 0
for j in range(n):
	s = 0
	for i in range(n):
		s += A[i][j]
	if s == n:
		c += 1
if k > 0 and c > 0:
	print(-1)
	exit(0)
if c > 0:
	for i in range(n):
		for j in range(n):
			if A[i][j] == 0:
				print(i + 1, j + 1)
				break
else:
	for j in range(n):
		for i in range(n):
			if A[i][j] == 0:
				print(i + 1, j + 1)
				break


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)


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())
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
if X == 1 and Y == 1:
	print('-1')
elif 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


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(input())
A = [list(input()) for _ in range(n)]
r = c = 0
for i in range(n):
	if A[i].count('.') == 0:
		r += 1
for i in range(n):
	x = [A[j][i] for j in range(n)]
	if x.count('.') == 0:
		c += 1
if r > 0 and c > 0:
	print(-1)
	exit()
if c == 0:
	for i in range(n):
		for j in range(n):
			if A[j][i] == '.':
				print(j + 1, i + 1)
				break
elif r == 0:
	for i in range(n):
		for j in range(n):
			if A[i][j] == '.':
				print(i + 1, j + 1)
				break


n = int(input())
b = []
ok = 1
c = [0] * n
for i in range(n):
	a = input()
	oki = 1
	for j in range(n):
		if a[j] == '.':
			c[j] = c[j] + 1
			oki = 0
	if oki:
		ok = 0
	b.append(a)
if ok == 0:
	ok = 1
	for j in range(n):
		oki = 1
		for i in range(n):
			if b[i][j] == '.':
				oki = 0
		if oki:
			ok = 0
	if ok == 0:
		print('-1')
	else:
		for j in range(n):
			p = 0
			for i in range(n):
				if b[i][j] == '.':
					p = i
			print(p + 1, j + 1)
	ok = 0
if ok:
	for i in range(n):
		a = b[i]
		p = 0
		for j in range(n):
			if a[j] == '.':
				p = j
		print(i + 1, p + 1)