'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
div={}
def palace(N,M):
	for line_no in range(N):
		line=map(int, raw_input().split())
		for i,item in enumerate(line):
			div[item]=str(line_no)+' '+str(i)
	no_query=input()
	for i in range(no_query):
		query=input()
		try:
			print div[query]
		except:
			print '-1 -1'


v=map(int, raw_input().split())
palace(v[0],v[1])