import sys input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) n,k = list(map(int, input().split())) n = 100 t = int(input()) import random _a = [random.randint(0,1) for _ in range(n+1)] def UPD(i, v): print("UPD", i, v) _a[i] = v def AND(i, j, k): print("AND", i, j, k) _a[k] = _a[i] and _a[j] def XOR(i, j, k): print("XOR", i, j, k) _a[k] = _a[i]^_a[j] def swap(i,j): UPD(n,1) AND(i, j, i) XOR(j, n, j) XOR(i, n, n) AND(j, n, j) UPD(n,1) XOR(j, n, j) for i in range(1,n): for j in range(i)[::-1]: swap(j,j+1) UPD(n,0) XOR(k-1,n,n)