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 = [] res.append("UPD {} {}".format(i,1)) res.append("AND {} {} {}".format(i,i,j)) return res def sort(i,j,k): assert i < j """ ・ai <- ai(1-aj)+aj = ai^aj^(ai and aj) ・aj <- aiaj = (ai and aj) """ res = [] res += update_ai_by_aj(k,j) res.append("AND {} {} {}".format(j,i,j)) res.append("XOR {} {} {}".format(i,i,k)) res.append("XOR {} {} {}".format(i,i,j)) return res N,K = mi() res = [] for i in range(N): for j in range(N-1,i,-1): res += sort(j-1,j,N) res += update_ai_by_aj(N,K-1) print(len(res)) print(*res,sep="\n")