l=[int(x) for x in raw_input().split()]
l2=[]
for i in range(l[0]):
	l1=[int(y) for y in raw_input().split()]
	l2.append(l1)
for j in range(input()):
	a=input()
	l3=[]
	d=0
	for k in range(0,len(l2)):
		if(a in l2[k]):
			l3.append(k)
			break;
		else:
			d+=1
	if(d==len(l2)):
		print("-1 -1")
	else:
		print l3[0],l2[l3[0]].index(a)