from textwrap import indent


N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

index = list(range(N))

for _ in range(Q):
    cmd, x, y = map(int, input().split())
    match cmd:
        case 0:
            index[x], index[y] = index[y], index[x]
        case 1:
            print(A[index[x]][y])
        case _:
            assert False
