row_num, column_num = [int(s) for s in raw_input().split()]
rows = [[int(s) for s in raw_input().split()] for row in xrange(row_num)]
memory_num = int(raw_input())
memories = []
memory_output = []
for i in xrange(memory_num):
	memories.append(int (raw_input()))
	memory_output.append('-1 -1')
memory_set = set(memories)
for row_index, row in enumerate(rows):
	for match in set(row).intersection(memory_set):
		for i, memory in enumerate(memories):
			if memory == match:
				memory_output[i] = '{0} {1}'.format(row_index, row.index(match))
for output in memory_output:
	print output