Problem:
 Score : 600 points    Problem Statement Snuke is introducing a robot arm with the following properties to his factory:   The robot arm consists of m  sections and m+1  joints . The sections are numbered 1 , 2 , ..., m , and the joints are numbered 0 , 1 , ..., m . Section i connects Joint i-1 and Joint i . The length of Section i is d_i .  For each section, its mode can be specified individually. There are four modes: L , R , D and U . The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i) ):  (x_0, y_0) = (0, 0) .  If the mode of Section i is L , (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}) .  If the mode of Section i is R , (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}) .  If the mode of Section i is D , (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}) .  If the mode of Section i is U , (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}) .     Snuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.
Is this possible?
If so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j) .      Constraints  All values in input are integers.  1 \leq N \leq 1000  -10^9 \leq X_i \leq 10^9  -10^9 \leq Y_i \leq 10^9       Partial Score  In the test cases worth 300 points, -10 \leq X_i \leq 10 and -10 \leq Y_i \leq 10 hold.         Input Input is given from Standard Input in the following format:  N  X_1  Y_1  X_2  Y_2  :  X_N  Y_N       Output If the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1 .  m  d_1  d_2  ...  d_m  w_1  w_2  :  w_N   m and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.
Here, 1 \leq m \leq 40 and 1 \leq d_i \leq 10^{12} must hold. Also, m and d_i must all be integers.  w_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j) .
The i -th character of w_j should be one of the letters L , R , D and U , representing the mode of Section i .        Sample Input 1 3
-1 0
0 3
2 -1      Sample Output 1 2
1 2
RL
UU
DR  In the given way to bring Joint m of the robot arm to each (X_j, Y_j) , the positions of the joints will be as follows:   To (X_1, Y_1) = (-1, 0) : First, the position of Joint 0 is (x_0, y_0) = (0, 0) . As the mode of Section 1 is R , the position of Joint 1 is (x_1, y_1) = (1, 0) . Then, as the mode of Section 2 is L , the position of Joint 2 is (x_2, y_2) = (-1, 0) .  To (X_2, Y_2) = (0, 3) : (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3) .  To (X_3, Y_3) = (2, -1) : (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1) .        Sample Input 2 5
0 0
1 0
2 0
3 0
4 0      Sample Output 2 -1       Sample Input 3 2
1 1
1 1      Sample Output 3 2
1 1
RU
UR  There may be duplicated points among (X_j, Y_j) .       Sample Input 4 3
-7 -3
7 3
-3 -7      Sample Output 4 5
3 1 4 1 5
LRDUL
RDULR
DULRD

Solution (Python):
N = int(input())
XY = [[int(i) for i in input().split()] for _ in range(N)]

if len(set([(X + Y) % 2 for X, Y in XY])) != 1 :
    print(-1)
    
else :
    d = []
    for i in range(32, -1, -1) :
        d.append(1 << i)
    
    if (XY[0][0] + XY[0][1]) % 2 == 0 :
        d.append(1)
    
    print(len(d))
    print(*d)
    
    for X, Y in XY :
        ret = ''
        cx, cy = 0, 0
        for i in range(len(d)) :
            mj, mv = 0, float('inf')
            diff = [(d[i], 0), (-d[i], 0), (0, d[i]), (0, -d[i])]
            for j, (dx, dy) in enumerate(diff) :
                if (cx + dx - X) ** 2 + (cy + dy - Y) ** 2 < mv:
                    mj = j
                    mv = (cx + dx - X) ** 2 + (cy + dy - Y) ** 2
            
            if mj == 0 :
                ret += 'R'
                cx += d[i]
            elif mj == 1 :
                ret += 'L'
                cx -= d[i]
            elif mj == 2 :
                ret += 'U'
                cy += d[i]
            else :
                ret += 'D'
                cy -= d[i]
                
        print(ret)

Solution (Python):
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]

odd = []
for (x, y) in P:
    dist = abs(x) + abs(y)
    odd.append(dist % 2 != 0)

valid = True
even = False
if all(odd):
    pass
elif not any(odd):
    even = True
else:
    valid =False

if valid:

    M = 31
    if even:
        print(M+1)
        print(*([1 << m for m in range(M)] + [1]))
    else:
        print(M)
        print(*[1 << m for m in range(M)])

    for (x, y) in P:
        u = x + y
        v = x - y
        if even:
            u += 1
            v += 1
        if u >= 0 and v >= 0:
            A = 'R'
            B = 'U'
            C = 'D'
            D = 'L'
        elif u >= 0 and v < 0:
            v *= -1
            A = 'U'
            B = 'R'
            C = 'L'
            D = 'D'
        elif u < 0 and v >= 0:
            u *= -1
            A = 'D'
            B = 'L'
            C = 'R'
            D = 'U'
        elif u < 0 and v < 0:
            u *= -1
            v *= -1
            A = 'L'
            B = 'D'
            C = 'U'
            D = 'R'

        ans = ''
        wa = ((1 << M) - 1 - u) // 2
        sa = ((1 << M) - 1 - v) // 2
        for i in range(M):
            check = str(wa >> i & 1) + str(sa >> i & 1)
            if check == '00':
                ans += A
            elif check == '01':
                ans += B
            elif check == '10':
                ans += C
            elif check == '11':
                ans += D
        if even:
            ans += 'L'
        print(ans)
else:
    print(-1)

Solution (Python):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s = set([(x + y) % 2 for x, y in xy])
if len(s) > 1:
    print(-1)
    exit(0)

d = []
w = ["" for _ in xy]
if s.pop() == 0:
    d = [1]
    w = ["L" for _ in xy]
    xy = [(x + 1, y) for x, y in xy]

b = 1 << 30
while b > 0:
    d.append(b)
    for i in range(len(xy)):
        x, y = xy[i]
        if abs(x) > abs(y):
            if x > 0:
                w[i] += 'R'
                xy[i] = (x - b, y)
            else:
                w[i] += 'L'
                xy[i] = (x + b, y)
        else:
            if y > 0:
                w[i] += 'U'
                xy[i] = (x, y - b)
            else:
                w[i] += 'D'
                xy[i] = (x, y + b)
    b //= 2

print(len(d))
print(*d)
for t in w:
    print(t)

Solution (Python):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s = set([(x + y) % 2 for x, y in xy])
if len(s) > 1:
    print(-1)
    exit(0)

d = []
w = ["" for _ in xy]
if s.pop() == 0:
    d = [1]
    w = ["L" for _ in xy]
    xy = [(x + 1, y) for x, y in xy]

b = 1
while True:
    if all(abs(x) + abs(y) == 1 for x, y in xy):
        d.append(b)
        for i in range(len(xy)):
            x, y = xy[i]
            if x > 0:
                w[i] += 'R'
            elif x < 0:
                w[i] += 'L'
            elif y > 0:
                w[i] += 'U'
            else:
                w[i] += 'D'
        break
    d.append(b)
    for i in range(len(xy)):
        x, y = xy[i]
        if x % 2 == 1:
            if y % 4 == 2 and (x - 1) % 4 == 0 or y % 4 == 0 and (x - 1) % 4 == 2:
                w[i] += 'R'
                xy[i] = ((x - 1) // 2, y // 2)
            else:
                w[i] += 'L'
                xy[i] = ((x + 1) // 2, y // 2)
        else:
            if x % 4 == 2 and (y - 1) % 4 == 0 or x % 4 == 0 and (y - 1) % 4 == 2:
                w[i] += 'U'
                xy[i] = (x // 2, (y - 1) // 2)
            else:
                w[i] += 'D'
                xy[i] = (x // 2, (y + 1) // 2)
    b *= 2

print(len(d))
print(*d)
for t in w:
    print(t)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n = S()
    for i in n:
        if i == "1":
            print(9, end="")
        else:
            print(1, end="")
    print()
    return


def B():
    n = II()
    for i in range(111, 1000, 111):
        if n <= i:
            print(i)
            return
    return


def C():
    return






def D():
    n = II()
    xy = LIR(n)
    xy_ = [a + b for a, b in xy]
    RULD = ["R", "U", "L", "D"]
    R = 0
    if len(set(map(lambda x: x & 1, xy_))) == 2:
        print(-1)
        return
    ans = [1 << i for i in range(33)]
    f = (xy[0][0] + xy[0][1]) & 1 ^ 1
    if f: ans = [1] + ans
    xy = [[abs(x - f), abs(y), ((x - f) < 0) << 0 | (y < 0) << 1] for x, y in xy]
    lis = []
    for x, y, p in xy:
        b = (x & 1) ^ 1
        tmp = [b]
        for i in range(1,33):
            if b == R:
                if x >> i & 1:
                    if y >> i & 1:
                        k = i
                        while x >> k & 1:
                            x ^= 1 << k
                            k += 1
                        x ^= 1 << k
                        tmp[-1] ^= 2
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp.append(b)
                else:
                    if y >> i & 1:
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp[-1] ^= 2
                        tmp.append(b)
            else:
                if y >> i & 1:
                    if x >> i & 1:
                        k = i
                        while y >> k & 1:
                            y ^= 1 << k
                            k += 1
                        y ^= 1 << k
                        tmp[-1] ^= 2
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp.append(b)
                else:
                    if x >> i & 1:
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp[-1] ^= 2
                        tmp.append(b)
        for i in range(33):
            if p & 1:
                if tmp[i] & 1 ^ 1:
                    tmp[i] ^= 2
            if p & 2:
                if tmp[i] & 1:
                    tmp[i] ^= 2
        lis.append(map(lambda x: RULD[x], tmp))
    print(33+f)
    print(*ans)
    for a in lis:
        print("R"*f+"".join(a))
    return



if __name__ == '__main__':
    D()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n = S()
    for i in n:
        if i == "1":
            print(9, end="")
        else:
            print(1, end="")
    print()
    return


def B():
    n = II()
    for i in range(111, 1000, 111):
        if n <= i:
            print(i)
            return
    return


def C():
    return






def D():
    n = II()
    xy = LIR(n)
    xy_ = [a + b for a, b in xy]
    RULD = ["R", "U", "L", "D"]
    R = 0
    if len(set(map(lambda x: x & 1, xy_))) == 2:
        print(-1)
        return
    ans = [1 << i for i in range(39)]
    f = (xy[0][0] + xy[0][1]) & 1 ^ 1
    if f: ans = [1] + ans
    xy = [[abs(x - f), abs(y), ((x - f) < 0) << 0 | (y < 0) << 1] for x, y in xy]
    lis = []
    for x, y, p in xy:
        b = (x & 1) ^ 1
        tmp = [b]
        for i in range(1,39):
            if b == R:
                if x >> i & 1:
                    if y >> i & 1:
                        k = i
                        while x >> k & 1:
                            x ^= 1 << k
                            k += 1
                        x ^= 1 << k
                        tmp[-1] ^= 2
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp.append(b)
                else:
                    if y >> i & 1:
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp[-1] ^= 2
                        tmp.append(b)
            else:
                if y >> i & 1:
                    if x >> i & 1:
                        k = i
                        while y >> k & 1:
                            y ^= 1 << k
                            k += 1
                        y ^= 1 << k
                        tmp[-1] ^= 2
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp.append(b)
                else:
                    if x >> i & 1:
                        b ^= 1
                        tmp.append(b)
                    else:
                        tmp[-1] ^= 2
                        tmp.append(b)
        for i in range(39):
            if p & 1:
                if tmp[i] & 1 ^ 1:
                    tmp[i] ^= 2
            if p & 2:
                if tmp[i] & 1:
                    tmp[i] ^= 2
        lis.append(map(lambda x: RULD[x], tmp))
    print(39+f)
    print(*ans)
    for a in lis:
        print("R"*f+"".join(a))
    return



if __name__ == '__main__':
    D()

Solution (Python):
import sys
input = sys.stdin.readline

import bisect

N=int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
r=(XY[0][0]+XY[0][1])%2
for i in range(N):
    if r != (XY[i][0]+XY[i][1])%2:
        print(-1)
        sys.exit()

sumtwo=[]
mul = 2
for i in range(31):
    sumtwo.append(mul - 1)
    mul*=2


maxtwo=0
i_two=0
for i in range(N):
    if maxtwo < abs(XY[i][0])+abs(XY[i][1]):
        i_two = bisect.bisect_left(sumtwo, abs(XY[i][0])+abs(XY[i][1]))
        maxtwo = sumtwo[i_two]
ans=[2**i for i in range(i_two+1)]
if r==0:
    ans=[1]+ans
    i_two+=1
print(i_two+1)
print(*ans)
ans.reverse()

for i in range(N):
    ans2 = []
    nowx,nowy=XY[i]
    for j in range(i_two+1):
        if abs(nowx) < abs(nowy):
            if nowy < 0:
                ans2.append("D")
                nowy += ans[j]
            else:
                ans2.append("U")
                nowy -= ans[j]
        else:
            if nowx < 0:
                ans2.append("L")
                nowx += ans[j]
            else:
                ans2.append("R")
                nowx -= ans[j]
    ans2.reverse()
    print("".join(ans2))

Solution (Python):
from functools import reduce
import math

n = int(input())
coord = [tuple(map(int, input().split())) for i in range(n)]


x, y = coord[0]
p = (x + y) & 1
limit = 0
for x, y in coord:
    if p != (x + y) & 1:
        print(-1)
        exit()
    lim = abs(x) + abs(y)
    if lim > limit:
        limit = lim

limit = round(math.log2(limit))
if p == 1:
    d = [2 ** i for i in reversed(range(limit + 1))]
else:
    d = [1] + [2 ** i for i in reversed(range(limit + 1))]

print(len(d))
print(reduce((lambda acc, dist: str(acc) + " " + str(dist)), d))

for x, y in coord:
    u = x + y
    v = x - y

    command = ""
    for i in range(len(d)):
        if u >= 0 and v >= 0:
            command += "R"
            u -= d[i]
            v -= d[i]
        elif u >= 0 > v:
            command += "U"
            u -= d[i]
            v += d[i]
        elif u < 0 <= v:
            command += "D"
            u += d[i]
            v -= d[i]
        elif u < 0 and v < 0:
            command += "L"
            u += d[i]
            v += d[i]

    print(command)

Solution (Python):
n = int(input())

P = []
M = []
for _ in range(n):
  x, y = map(int, input().split())
  P.append((x, y))
  M.append((x + y) % 2)

if len(set(M)) == 2:
  print(-1)
  exit()

D = [1 << i for i in range(31, -1, -1)]
if M[0] == 0:
  D.append(1)

print(len(D))
print(*D, sep=' ')

for x, y in P:
  a = []
  for d in D:
    if abs(x) > abs(y):
      if x < 0:
        a.append('L')
        x += d
      else:
        a.append('R')
        x -= d
    else:
      if y < 0:
        a.append('D')
        y += d
      else:
        a.append('U')
        y -= d
  print(*a, sep='')

Solution (Python):
n,*t=map(int,open(0).read().split())
*z,=zip(t[::2],t[1::2])
s=set((a+b)%2for a,b in z)
if len(s)>1:
  print(-1)
  exit()
s,*_=s
d=[2**(38-i)for i in range(39)]+[1]*(s<1)
print(len(d),*d)
for a,b in z:
  x=y=0
  o=''
  for i in d:
    if abs(a-x)>abs(b-y):
      f=a-x>0
      o+='LR'[f]
      x+=i*f or-i
    else:
      f=b-y>0
      o+='DU'[f]
      y+=i*f or-i
  print(o)

Solution (Python):
n,*t=map(int,open(0).read().split())
*z,=zip(t[::2],t[1::2])
s=set((a+b)%2for a,b in z)
if len(s)>1:
    print(-1)
    exit()
s,*_=s
d=[2**(38-i)for i in range(39)]+[1]*(s<1)
print(len(d))
print(*d)
for a,b in z:
    x=y=0
    for i in d:
        if abs(a-x)>abs(b-y):
            if a-x>0:
                print('R',end='')
                x+=i
            else:
                print('L',end='')
                x-=i
        else:
            if b-y>0:
                print('U',end='')
                y+=i
            else:
                print('D',end='')
                y-=i
    print()

Solution (Python):
n,*t=map(int,open(0).read().split())
*z,=zip(t[::2],t[1::2])
s=set((a+b)%2for a,b in z)
if len(s)>1:
    print(-1)
    exit()
s,*_=s
d=[2**(38-i)for i in range(39)]+[1]*(s<1)
print(len(d))
print(*d)
for a,b in z:
    x=y=0
    for i in d:
        if abs(a-x)>abs(b-y):
            if a-x>0:
                print('R',end='')
                x+=i
            else:
                print('L',end='')
                x-=i
        else:
            if b-y>0:
                print('U',end='')
                y+=i
            else:
                print('D',end='')
                y-=i
    print()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = S()
    for i in n:
        if i == "1":
            print(9,end = "")
        else:
            print(1,end = "")
    print()

def B():
    n = I()
    for i in range(n,1000):
        if i%111 == 0:
            print(i)
            quit()
    return


def C():
    return


def D():
    """
     長さ1<<i(0<=i<39)のアームがあると仮定し、大きいほうアームからいける点をプロットしていくと、フラクタルのような図形が描ける。
    最終到達可能点に着目すると、マンハッタン距離が2で割り切れる点どうししか到達できないことが分かる。→mod2が1なら-1を出力。

     構築を考える。まず長さ1のアームがあることから、どちらか片方のみ奇数である必要がある。もしともに偶数、奇数であれば、
    長さ1のアームを追加して、スタート地点を(1,0)とすることで帳尻があう。
     まずx方向のみで考える。xのibit目(右から見て)がたっているとき、…R…、もしくは、…LR…と移動することでibit目を消すことができる。
    すべてのアームを利用する必要があることから、小さいほうから帰納的に、
     ibit目がたっている   → Rを追加
     ibit目がたっていない → 末尾のRを反転し、Rを追加

    とすることですべてのアームを使うことができる。

    例：アームが5本(1,2,4,8,16)のとき
       x = 9(0b01001)を作りたい
       w = [] : xへ到達するモードの指定方法
       右のbitから評価 ()内の数字が現時点の座標
       0bit目がたっている
       →Rを追加              : w = R (1)

       1bit目がたっていない
       →末尾を反転し、Rを追加 : w = LR (1)

       2bit目がたっていない
       →末尾を反転し、Rを追加 : w = LLR (1)

       3bit目がたっている
       →Rを追加              : w = LLRR (9)

       4bit目がたっていない
       →末尾を反転し、Rを追加 : w = LLRLR (9)


     y方向も含めて考える。同じく帰納的に小さいほうから考えていく。
    x,yのibit目が(0,0),(0,1),(1,0),(1,1)の4通りがある。すべてのアームを利用することから、
     i番目が(0,0) → 末尾を反転、(i-1)番目でRを追加したのであれば、Rを追加。Uを追加したのであれば、Uを追加
     i番目が(0,1) → Uを追加
     i番目が(1,0) → Rを追加

    と3つはこのようにすればよいと簡単に導ける。残りの(1,1)の場合を考える。片方の方向にしかアームを使えないため、
    より大きなアームで一方を補う必要がある。1つ以上の連続するビットを消すことができれば、x,yの和が奇数(0bit目が片方のみ立っている)
    であることから実現することができる。[i, j) (i<j)のbitがたっているとき、この和は
     2**i+2**(i+1)+2**(i+2)+…+2**(j-1) = 2**j-2**iと表せる。
    ゆえに連続してbitがたっている区間[i,j)に対し、末尾を反転(-2**i)、
    (i,j)のbitを0に、j番目のbitを1にする(+2**j)という操作をおこなえば良い。
    まとめると、
     i番目が(0,0) → 末尾を反転、(i-1)番目でRを追加したのであれば、Rを追加。Uを追加したのであれば、Uを追加
     i番目が(0,1) → Uを追加
     i番目が(1,0) → Rを追加
     i番目が(1,1) → 末尾を反転、(i-1)番目でRを追加したのであれば、xについてbitがたっている区間[i,j)のbitを0に、j番目のbitを1にする。
                   Uを追加したのであれば、yについてbitがたっている区間[i,j)のbitを0に、j番目のbitを1にする。

    """
    n = I()
    p = LIR(n)
    b = []
    for i in range(n):
        x,y = p[i]
        for j in range(i):
            s,t = p[j]
            if (abs(x-s)+abs(y-t))%2:
                print(-1)
                return
    ans = []
    for i in range(n):
        f = 0
        x,y = p[i]
        if not (x+y)%2:
            x -= 1
            if not ans:
                ans.append(1)
        if x < 0:
            x = -x
            f |= 1
        if y < 0:
            y = -y
            f |= 2
        bx = list(map(int, bin(x)[2:]))
        by = list(map(int, bin(y)[2:]))
        bx = bx[::-1]
        by = by[::-1]
        for _ in range(39-len(bx)):
            bx.append(0)
        for _ in range(39-len(by)):
            by.append(0)
        b.append([bx,by,f])
    for i in range(39):
        ans.append(1<<i)
    v = [[] for i in range(n)]
    for i in range(n):
        x,y,f = b[i]
        if x[0]:
            p = 1
            v[i].append(0)
        else:
            p = 0
            v[i].append(1)
        for j in range(1,39):
            if p:
                if x[j]:
                    if y[j]:
                        v[i][-1] ^= 3
                        k = j+1
                        while x[k]:
                            x[k] ^= 1
                            k += 1
                        x[k] = 1
                        v[i].append(1)
                        p = 0
                    else:
                        v[i].append(0)
                else:
                    if y[j]:
                        v[i].append(1)
                        p = 0
                    else:
                        v[i][-1] ^= 3
                        v[i].append(0)
            else:
                if y[j]:
                    if x[j]:
                        v[i][-1] ^= 3
                        k = j+1
                        while y[k]:
                            y[k] ^= 1
                            k += 1
                        y[k] = 1
                        v[i].append(0)
                        p = 1
                    else:
                        v[i].append(1)
                else:
                    if x[j]:
                        v[i].append(0)
                        p = 1
                    else:
                        v[i][-1] ^= 3
                        v[i].append(1)
        for j in range(39):
            if v[i][j] in [0,3]:
                if f&1:
                    v[i][j]^=3
            else:
                if f&2:
                    v[i][j]^=3
    p = ["R","U","D","L"]
    print(len(ans))
    print(*ans)
    for i in v:
        if len(ans) == 40:
            print("R",end = "")
        for j in i:
            print(p[j],end = "")
        print()
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    D()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = S()
    for i in n:
        if i == "1":
            print(9,end = "")
        else:
            print(1,end = "")
    print()

def B():
    n = I()
    for i in range(n,1000):
        if i%111 == 0:
            print(i)
            quit()
    return


def C():
    return


def D():
    n = I()
    p = LIR(n)
    b = []
    for i in range(n):
        x,y = p[i]
        for j in range(i):
            s,t = p[j]
            if (abs(x-s)+abs(y-t))%2:
                print(-1)
                return
    ans = []
    for i in range(n):
        f = 0
        x,y = p[i]
        if not (x+y)%2:
            x -= 1
            if not ans:
                ans.append(1)
        if x < 0:
            x = -x
            f |= 1
        if y < 0:
            y = -y
            f |= 2
        bx = list(map(int, bin(x)[2:]))
        by = list(map(int, bin(y)[2:]))
        bx = bx[::-1]
        by = by[::-1]
        for _ in range(39-len(bx)):
            bx.append(0)
        for _ in range(39-len(by)):
            by.append(0)
        b.append([bx,by,f])
    for i in range(39):
        ans.append(1<<i)
    v = [[] for i in range(n)]
    for i in range(n):
        x,y,f = b[i]
        if x[0]:
            p = 1
            v[i].append(0)
        else:
            p = 0
            v[i].append(1)
        for j in range(1,39):
            if p:
                if x[j]:
                    if y[j]:
                        v[i][-1] ^= 3
                        k = j+1
                        while x[k]:
                            x[k] ^= 1
                            k += 1
                        x[k] = 1
                        v[i].append(1)
                        p = 0
                    else:
                        v[i].append(0)
                else:
                    if y[j]:
                        v[i].append(1)
                        p = 0
                    else:
                        v[i][-1] ^= 3
                        v[i].append(0)
            else:
                if y[j]:
                    if x[j]:
                        v[i][-1] ^= 3
                        k = j+1
                        while y[k]:
                            y[k] ^= 1
                            k += 1
                        y[k] = 1
                        v[i].append(0)
                        p = 1
                    else:
                        v[i].append(1)
                else:
                    if x[j]:
                        v[i].append(0)
                        p = 1
                    else:
                        v[i][-1] ^= 3
                        v[i].append(1)
        for j in range(39):
            if v[i][j] in [0,3]:
                if f&1:
                    v[i][j]^=3
            else:
                if f&2:
                    v[i][j]^=3
    p = ["R","U","D","L"]
    print(len(ans))
    print(*ans)
    for i in v:
        if len(ans) == 40:
            print("R",end = "")
        for j in i:
            print(p[j],end = "")
        print()
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    D()

Solution (Python):
N=int(input())

point = []
parity = {}
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    parity[(x + y) % 2] = 1

if len(set(parity)) == 2 :
    print('-1')
else :
    m = 38
    parity = 1 if (1 in parity) else 0
    print(m + 1 - parity)
    if parity == 1 :  
        print(*[1 << i for i in range(m)])
    else :
        print(1, *[1 << i for i in range(m)])

    def arm(x, y, m) :
        if abs(x) >= abs(y) :
            if x >= 0 :
                return ('R', x - (1<<m), y)
            else :
                return ('L', x + (1<<m), y)
        else :
            if y >= 0 :
                return ('U', x, y - (1<<m))
            else :
                return ('D', x, y + (1<<m))

    for x, y in point :
        ans = []
        for i in range(m-1, -1, -1) :
            mode, x, y = arm(x, y, i)
            ans.append(mode)
        if parity == 0 :  
            if x == 1 :
                ans.append('R')
            elif x == -1 :
                ans.append('L')
            elif y == 1 :
                ans.append('U')
            elif y == -1 :
                ans.append('D')
        print(''.join(ans[::-1]))

Solution (Python):
import sys
input = sys.stdin.readline

N=int(input())
ARM=[list(map(int,input().split())) for i in range(N)]

OE=[(ARM[i][0]+ARM[i][1])%2 for i in range(N)]

if len(set(OE))==2:
    print(-1)
    sys.exit()

if OE[0]==1:
    
    m=38
    print(m)
    print(*[1<<i for i in range(m)])

    def URLD(x,y,m):
        
        if abs(x)>=abs(y):
            if x>=0:
                return "R",(x-(1<<m),y)
            else:
                return "L",(x+(1<<m),y)

        else:
            if y>=0:
                return "U",(x,y-(1<<m))
            else:
                return "D",(x,y+(1<<m))

    for x,y in ARM:
        ANS=[]
        for i in range(m-1,-1,-1):
            a,(x,y)=URLD(x,y,i)
            ANS.append(a)

        print("".join(ANS[::-1]))
        
else:

    m=39
    print(m)
    print(1,*[1<<i for i in range(m-1)])

    def URLD(x,y,m):
        
        if abs(x)>=abs(y):
            if x>=0:
                return "R",(x-(1<<m),y)
            else:
                return "L",(x+(1<<m),y)

        else:
            if y>=0:
                return "U",(x,y-(1<<m))
            else:
                return "D",(x,y+(1<<m))

    for x,y in ARM:
        ANS=[]
        for i in range(m-2,-1,-1):
            a,(x,y)=URLD(x,y,i)
            ANS.append(a)

        if x==1:
            ANS.append("R")
        elif x==-1:
            ANS.append("L")
        elif y==1:
            ANS.append("U")
        else:
            ANS.append("D")

        print("".join(ANS[::-1]))