r, c = map(int, input().split())
a = [list(map(int, input().split())), list(map(int, input().split()))]
print(a[r - 1][c - 1])

cb4b4bab8e328e3dbaf8fdce9083f47947ae56b0
<mask token>

<mask token>
print(a[r - 1][c - 1])

r, c = map(int, input().split())
a = [list(map(int, input().split())), list(map(int, input().split()))]
print(a[r - 1][c - 1])
