import sys from sys import stdin from collections import deque def UPD(i,x): for vv in range(T): C[vv][i] = x print ("UPD",i,x) def AND(i,j,k): for vv in range(T): C[vv][i] = C[vv][j] & C[vv][k] print ("AND",i,j,k) def XOR(i,j,k): for vv in range(T): C[vv][i] = C[vv][j] ^ C[vv][k] print ("XOR",i,j,k) def SWAP(i): UPD(N,1) XOR(N,i+1,N) AND(N,i,N) XOR(i,i,N) XOR(i+1,i+1,N) N,K = map(int,stdin.readline().split()) T = int(stdin.readline()) C = [list(map(int,stdin.readline().split()))+[0] for i in range(T)] #C = [1,1,0,1,0,0,1,0,0,0,1,0] #N = len(C)-1 for i in range(N-1,-1,-1): for j in range(i+1): SWAP(j) UPD(N,0) XOR(N,N,N-K) print (C,file = sys.stderr) #T = int(stdin.readline())