def UPD(i,x): ans.append(f"UPD {i} {x}") def AND(i,j,k): ans.append(f"AND {i} {j} {k}") def XOR(i,j,k): ans.append(f"XOR {i} {j} {k}") n,k = map(int,input().split()) ans = [] for i in range(1,n): for j in range(i): AND(n,i,j) XOR(j,i,j) UPD(i,0) XOR(i,i,n) if k&1: UPD(n,0) XOR(n,0,n) else: UPD(n,1) k //= 2 for i in range(1,n): if k&1: AND(n,i,n) else: AND(0,i,n) XOR(n,i,n) XOR(n,0,n) k //= 2 print(len(ans)) print("\n".join(ans))