import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def update_ai_by_aj(i,j): res = ["UPD {} {}".format(i,1),"AND {} {} {}".format(i,i,j)] return res def update_by_bool(b,i,j): """ ・b:Trueならaiをajでupdate ・b,jは破壊してok """ res = [] res.append("AND {} {} {}".format(j,b,j)) res.append("AND {} {} {}".format(b,b,i)) res.append("XOR {} {} {}".format(i,i,j)) res.append("XOR {} {} {}".format(i,i,b)) return res N,K = mi() res = [] res.append("AND {} {} {}".format(N,0,1)) res.append("XOR {} {} {}".format(0,0,1)) res += update_ai_by_aj(1,N) res.append("UPD {} {}".format(N,0)) up_memo = N AND_regi = 2 for b in range(2,N): if b+1 == 1<>i & 1)) res.append("XOR {} {} {}".format(AND_regi,i,AND_regi)) res += update_by_bool(AND_regi,N,i) res.append("UPD {} {}".format(AND_regi,0)) print(*res,sep="\n") #print(len(res)) """ check = li() A = [check[i] for i in range(N)] + [0] flag = False for s in res: op = [t for t in s.split()] if op[0]=="UPD": _,i,j = op i,j = int(i),int(j) A[i] = j elif op[0]=="AND": _,i,j,k = op print(i,j,k) i,j,k = int(i),int(j),int(k) A[i] = A[j]&A[k] elif op[0]=="XOR": _,i,j,k = op i,j,k = int(i),int(j),int(k) A[i] = A[j]^A[k] else: flag = True print(AND_regi) if flag: #print(A) print(A) print(A[N]) """