local read, p = io.read, print; local concat = table.concat; local function shortest_path(n, i, j, i2, j2, t) if (i2 - i) % 2 ~= 0 or ((j2 - j) % 2 == 0 and (i2 - i) % 4 == 2) then return nil; end if i > i2 and j > j2 then t[#t + 1] = 'UL'; return shortest_path(n, i-2, j-1, i2, j2, t); elseif i > i2 and j < j2 then t[#t + 1] = 'UR'; return shortest_path(n, i-2, j+1, i2, j2, t); elseif i == i2 and j < j2 then t[#t + 1] = 'R'; return shortest_path(n, i, j+2, i2, j2, t); elseif i < i2 and j < j2 then t[#t + 1] = 'LR'; return shortest_path(n, i+2, j+1, i2, j2, t); elseif i < i2 and j > j2 then t[#t + 1] = 'LL'; return shortest_path(n, i+2, j-1, i2, j2, t); elseif i == i2 and j > j2 then t[#t + 1] = 'L'; return shortest_path(n, i, j-2, i2, j2, t); elseif i == i2 and j == j2 then return t; elseif i < i2 and j == j2 then if j < n-2 then t[#t + 1] = 'LR'; return shortest_path(n, i+2, j+1, i2, j2, t); else t[#t + 1] = 'LL'; return shortest_path(n, i+2, j-1, i2, j2, t); end elseif i > i2 and j == j2 then if j > 1 then t[#t + 1] = 'UL'; return shortest_path(n, i-2, j-1, i2, j2, t); else t[#t + 1] = 'UR'; return shortest_path(n, i-2, j+1, i2, j2, t); end end end local n = read'n'; local priority = { UL=0, UR=1, R=2, LR=3, LL=4, L=5 }; local i, j, i2, j2 = read('n','n','n','n'); local path = shortest_path(n, i, j, i2, j2, { }); if path then table.sort(path, function(x,y) return priority[x] < priority[y]; end); p(#path); p(concat(path, ' ')); else p'Impossible'; end