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):
import sys



def 解():
    iN = int(input())
    aP = [[int(_) for _ in sLine.rstrip("\n").split()] for sLine in sys.stdin.readlines()]

    i最遠 = max([ abs(iX)+abs(iY) for iX , iY in aP])

    iMod = sum(aP[0]) % 2
    for i in range(1,iN):
        if sum(aP[i]) % 2 != iMod :
            print("-1")
            exit()
    a腕 = [1]
    if iMod == 0 :
        a腕 = [1,1]
    for i in range(32):
        a腕.append(a腕[-1] * 2)
        if i最遠 // 2 < a腕[-1]:
            break
    a腕.reverse()
    iLen腕 = len(a腕)
    print(iLen腕)
    print(" ".join([str(_) for _ in a腕]))
    aRet = []
    for aE in aP:
        aCommand=[]
        iX = aE[0]
        iY = aE[1]
        for i in range(iLen腕):
            if abs(iX) > abs(iY):
                if iX < 0 :
                    iX += a腕[i]
                    aCommand.append("L")
                else:
                    iX -= a腕[i]
                    aCommand.append("R")
            else:
                if iY < 0 :
                    iY += a腕[i]
                    aCommand.append("D")
                else:
                    iY -= a腕[i]
                    aCommand.append("U")
        aRet.append("".join(aCommand))
    sys.stdout.write("\n".join(aRet) + "\n")

if __name__ == '__main__':
    解()

Solution (Python):
import sys

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

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()

def calc(sx, sy, ex, ey, d):
    dx, dy = ex - sx, ey - sy
    if dx > dy:
        if dx > -dy:
            return "R", sx + d, sy
        else:
            return "D", sx, sy - d
    else:
        if dx > -dy:
            return "U", sx, sy + d
        else:
            return "L", sx - d, sy

import math

l = math.ceil(math.log(maxl + 1, 2))

ms = [1 << i for i in range(l)][::-1]

rms = ms

if mc[0] > 0:
    rms = [1] + ms

print(len(rms))
print(*rms)

for ex, ey in XY:
    x, y = 0, 0
    w = ""
    if mc[0] > 0:
        w = "R"
        x += 1
    for m in ms:
        d, x, y = calc(x, y, ex, ey, m)
        w += d
    print(w)

Solution (Python):
import sys

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

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()



def calc(sx, sy, ex, ey, d):
    dx, dy = ex - sx, ey - sy
    rx, ry = dx - dy, dx + dy
    if rx > 0:
        if ry > 0:
            d, x, y = "R", sx + d, sy
        else:
            d, x, y = "D", sx, sy - d
    else:
        if ry > 0:
            d, x, y = "U", sx, sy + d
        else:
            d, x, y = "L", sx - d, sy
    return d, x, y

import math

l = math.ceil(math.log(maxl + 1, 2))

ms = [2 ** (l - i - 1) for i in range(l)]

rms = ms

if mc[0] > 0:
    rms = [1] + ms

print(len(rms))
print(*rms)

for ex, ey in XY:
    x, y = 0, 0
    w = ""
    if mc[0] > 0:
        w = "R"
        x += 1
    for m in ms:
        d, x, y = calc(x, y, ex, ey, m)
        w += d
    print(w)

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

XY = []
parity = []
for _ in range(N):
    xy = list(map(int, input().split()))
    XY.append(xy)
    parity.append(sum(xy))


def check(ds, l, xy):
    x = 0
    y = 0
    for i in range(len(ds)):
        if l[i] == "R":
            x += ds[i]
        elif l[i] == "L":
            x -= ds[i]
        elif l[i] == "U":
            y += ds[i]
        elif l[i] == "D":
            y -= ds[i]
        else:
            raise Exception

    return (x == xy[0]) & (y == xy[1])


if len(list(set([i % 2 for i in parity]))) == 2:
    print(-1)

elif parity[0] % 2 == 0:
    print(33)
    ds = [1, 1] + [2 ** k for k in range(1, 32)]
    print(*ds)
    for xy in XY:
        rev_ans = ""
        curr_x, curr_y = 0, 0
        for d in ds[::-1]:
            x_diff = xy[0] - curr_x
            y_diff = xy[1] - curr_y
            if abs(x_diff) >= abs(y_diff):
                if x_diff >= 0:
                    rev_ans += "R"
                    curr_x += d
                else:
                    rev_ans += "L"
                    curr_x -= d
            else:
                if y_diff >= 0:
                    rev_ans += "U"
                    curr_y += d
                else:
                    rev_ans += "D"
                    curr_y -= d

        print(rev_ans[::-1])
        


else:  
    print(32)
    ds = [2 ** k for k in range(32)]
    print(*ds)
    for xy in XY:
        rev_ans = ""
        curr_x, curr_y = 0, 0
        for d in ds[::-1]:
            x_diff = xy[0] - curr_x
            y_diff = xy[1] - curr_y
            if abs(x_diff) >= abs(y_diff):
                if x_diff >= 0:
                    rev_ans += "R"
                    curr_x += d
                else:
                    rev_ans += "L"
                    curr_x -= d
            else:
                if y_diff >= 0:
                    rev_ans += "U"
                    curr_y += d
                else:
                    rev_ans += "D"
                    curr_y -= d

        print(rev_ans[::-1])

Solution (Python):
n = int(input())
xys = [list(map(int, input().split())) for _ in range(n)]


p = sum(xys[0]) % 2
for xy in xys:
    x, y = xy
    if (x + y) % 2 != p: 
        print(-1)
        exit()

if p == 0:
    d = [1]
else:
    d= []

d += [2 ** k for k in range(30 + 1)] 
m = len(d)

ws = [['' for _ in range(m)] for _ in range(n)]
idx = 0
for xy in xys:
    x, y = xy
    for k in sorted(range(m), reverse=True):
        R = abs(x - d[k]) + abs(y)
        L = abs(x + d[k]) + abs(y)
        U = abs(x) + abs(y - d[k])
        D = abs(x) + abs(y + d[k])

        min_v = min(R, L, U, D)

        if min_v == R:
            ws[idx][k] = 'R'
            x -= d[k]
        elif min_v == L:
            ws[idx][k] = 'L'
            x += d[k]
        elif min_v == U:
            ws[idx][k] = 'U'
            y -= d[k]
        else:
            
            ws[idx][k] = 'D'
            y += d[k]
    idx += 1

print(m)
print(*d)
for w in ws:
    print(''.join(w))

Solution (Python):
import sys

N = int(input())

co = []
x, y = map(int, input().split())
co.append((x, y))
Amod = (x + y) % 2
flag = True
max_co = abs(x) + abs(y)
for i in range(N - 1):
    x, y = map(int, input().split())
    co.append((x, y))

    if(Amod != (x + y) % 2):
        flag = False

    tmp = abs(x) + abs(y)
    max_co = max(max_co, tmp)

if(flag is False):
    print(-1)
    sys.exit()

ex2 = [1, 2, 4, 8, 16, 32]
expo = 32

while(expo < max_co):
    expo *= 2
    ex2.append(expo)


ans_list = []
for x, y in co:
    if Amod == 0:
        x -= 1
        ans = "R"
    else:
        ans = ""

    for arm in reversed(ex2):
        
        if abs(x) > abs(y):
            if x > 0:
                x -= arm
                ans = "R" + ans
            else:
                x += arm
                ans = "L" + ans
        else:
            if y > 0:
                y -= arm
                ans = "U" + ans
            else:
                y += arm
                ans = "D" + ans
    

    ans_list.append(ans)

if Amod == 0:
    ex2.append(1)

print(len(ex2))
arm = ""
for a in ex2:
    arm += " " + str(a)
print(arm[1:])
for a in ans_list:
    print(a)

Solution (Python):
import sys

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

mod = sum(XY[0]) % 2
if any(mod != ((x+y)%2) for x, y in XY):
    print(-1)
    sys.exit()

m = 33 - mod
print(m)
D = [2 ** i for i in range(31, -1, -1)]
if mod == 0:
    D.append(1)

print(' '.join(map(str, D)))
for x, y in XY:
    w = ''
    for d in D:
        if 0 <= x - y and 0 <= x + y:
            w += 'R'
            x -= d
        elif 0 > x - y and 0 <= x + y:
            w += 'U'
            y -= d
        elif 0 <= x - y and 0 > x + y:
            w += 'D'
            y += d
        else:
            w += 'L'
            x += d
    print(w)

Solution (Python):
import sys

N = int(input())
XY = list()
for i in range(N):
    XY.append(list(map(int, input().split(" "))))

eo = sum(XY[0]) % 2
for xy in XY:
    if (sum(xy) % 2 != eo):
        print(-1)
        sys.exit()

m = 40 - eo
print(m)
D = [2 ** i for i in range(38, -1, -1)]
if eo == 0:
    D.append(1)

print(" ".join(map(str, D)))
for x, y in XY:
    w = ""
    for i in range(m):
        if 0 <= x - y and 0 <= x + y:
            w += "R"
            x -= D[i]
        elif 0 > x - y and 0 <= x + y:
            w += "U"
            y -= D[i]
        elif 0 <= x - y and 0 > x + y:
            w += "D"
            y += D[i]
        else:
            w += "L"
            x += D[i]
    print(w)

Solution (Python):
n = int(input())
xy = []
flag = "f"
for i in range(0,n):
    X,Y = map(int,input().split())
    xy.append((X,Y))
    if i == 0:
        m = (X+Y)%2
    if m != (X+Y)%2:
        flag = "t"
if flag == "t":
    print(-1)
    exit()

d = [2**i for i in range(31,-1,-1)]

if m == 0:
    d.append(1)

print(len(d))
for i in range(0,len(d)):
    print(d[i],end = " ")
print()
for i in range(0,n):
    x,y = xy[i]
    w = ""
    for j in range(0,len(d)):
        if y <= x and  y >= -x:
            w += "R"
            x -= d[j]
        elif y >= x and y >= -x:
            w += "U"
            y -= d[j]
        elif y > x and y < -x:
            w += "L"
            x += d[j]
        else:
            w += "D"
            y += d[j]
    print(w)

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

N = int(fin())
coords = [[int(elem) for elem in fin().split(' ')] for _ in range(N)]
odd_or_even = abs((coords[0][0] + coords[0][1]) % 2)
max_sum = 0
for coord in coords:
    x, y = coord
    if (x + y) % 2 != odd_or_even:
        print(-1)
        exit(0)
    else:
        max_sum = max(max_sum, abs(x) + abs(y))


def partial_solution(max_sum, coords):
    m = max_sum
    print(m)
    print(' '.join(['1'] * m))
    for coord in coords:
        x, y = coord
        count = 0
        output = ""
        if x > 0:
            output += "R" * x
        else:
            output += "L" * abs(x)
        count += abs(x)

        if y > 0:
            output += "U" * y
        else:
            output += "D" * y
        count += abs(y)

        assert (m - count) % 2 == 0
        output += "LR" * ((m - count) // 2)
        print(output)


def padding(binary_expression):
    len_pad = 31 - len(binary_expression[2:])
    return "0" * len_pad + binary_expression[2:]


def full_solution(max_sum, coords, odd_or_even):
    mode_map = {(0, 0): "L",
                (1, 1): "R",
                (0, 1): "D",
                (1, 0): "U"}
    rotated_coords = [(x + y, x - y) for x, y in coords]
    d = []
    for i in range(31):
        d.append(2**i)  
    if odd_or_even == 1:
        m = 31
    else:
        m = 32
        d.append(1)
    print(m)
    print(" ".join([str(d_elem) for d_elem in d]))
    if odd_or_even == 1:
        for rotated_coord in rotated_coords:
            u, v = rotated_coord
            const_2pow31 = 2**31
            flags_u = list(padding(bin((u + const_2pow31 - 1) // 2)))[::-1]
            flags_v = list(padding(bin((v + const_2pow31 - 1) // 2)))[::-1]
            flags = [(int(fu), int(fv)) for fu, fv in zip(flags_u, flags_v)]
            output = "".join([mode_map[flag] for flag in flags])
            print(output)
    else:
        for rotated_coord in rotated_coords:
            u, v = rotated_coord
            u -= 1
            v -= 1
            const_2pow31 = 2**31
            flags_u = list(padding(bin((u + const_2pow31 - 1) // 2)))[::-1]
            flags_v = list(padding(bin((v + const_2pow31 - 1) // 2)))[::-1]
            flags = [(int(fu), int(fv)) for fu, fv in zip(flags_u, flags_v)]
            output = "".join([mode_map[flag] for flag in flags]) + "R"
            print(output)

full_solution(max_sum, coords, odd_or_even)

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

num_type = sum(XY[0])%2 
for xy in XY:
    if(sum(xy)%2 != num_type):
        print(-1)
        break
else:
    m = 40-num_type
    print(m)
    D = [2**i for i in range(38,-1,-1)]
    if not(num_type):
        D.append(1)

    print(' '.join(map(str,D)))
    for xy in XY:
        p = xy
        w = ""
        for i in range(m):
            if 0<=p[0]-p[1] and 0<=p[0]+p[1]:
                w += "R"
                p[0] -= D[i]
            elif 0>p[0]-p[1] and 0<=p[0]+p[1]:
                w += "U"
                p[1] -= D[i]
            elif 0<=p[0]-p[1] and 0>p[0]+p[1]:
                w += "D"
                p[1] += D[i]
            else:
                w += "L"
                p[0] += D[i]
        print(w)

Solution (Python):

"""
Created on Sun Sep 30 09:02:42 2018
ABC111D
@author: maezawa
"""
import sys
input = sys.stdin.readline

n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))
    

m = 1
parity = sum(xy[0])%2
far = 0
for point in xy:
    length = sum(list(map(abs, point)))
    if length > far:
        far = length
    if length%2 != parity:
        m = -1

if m == -1:
    print(m)
else:
    if parity == 0:
        ds = [1,1]
    else:
        ds = [1,1,1]
    i = 1
    while 2**i < far:
        ds.append(2**i)
        i += 1
    ds.append(2**i)
    ds.reverse()
    print(len(ds))
    print(*ds, sep=' ')
    for point in xy:
        direction = ''
        point0 = [0,0]
        for arm in ds:
            x = point[0] - point0[0]
            y = point[1] - point0[1]
            if abs(x) > abs (y):
                if x > 0:
                    direction += 'R'
                    point0[0] += arm
                else:
                    direction += 'L'
                    point0[0] -= arm
            else:
                if y > 0:
                    direction += 'U'
                    point0[1] += arm
                else:
                    direction += 'D'
                    point0[1] -= arm
            
        print(direction)

Solution (Python):
def d_robot_arms(N, Pos):
    
    ans = []

    pos = []
    
    parity = (abs(Pos[0][0]) + abs(Pos[0][1])) % 2
    for x, y in Pos:
        parity_current = (abs(x) + abs(y)) % 2
        if parity != parity_current:
            return -1
        pos.append([x - y, x + y])
        
        

    d = []
    
    for i in range(30, -1, -1):
        d.append(1 << i)
    if parity % 2 == 0:
        d.append(1)
    ans.append(str(len(d)))
    ans.append(' '.join(list(map(str, d))))

    for i in range(N):
        
        udir, vdir = 0, 0
        usum, vsum = 0, 0
        tmp = []
        for j in range(len(d)):
            if usum <= pos[i][0]:
                udir = 1
                usum += d[j]
            else:
                udir = -1
                usum -= d[j]

            if vsum <= pos[i][1]:
                vdir = 1
                vsum += d[j]
            else:
                vdir = -1
                vsum -= d[j]

            
            
            if udir == 1 and vdir == 1:
                tmp.append('R')
            elif udir == 1 and vdir == -1:
                tmp.append('D')
            elif udir == -1 and vdir == -1:
                tmp.append('L')
            else:
                tmp.append('U')
        ans.append(''.join(tmp))
    ans = '\n'.join(ans)
    return ans

N = int(input())
Pos = [[int(i) for i in input().split()] for j in range(N)]
print(d_robot_arms(N, Pos))

Solution (Python):
def d_robot_arms(N, Pos):
    
    ans = []

    pos = []
    parity = (abs(Pos[0][0]) + abs(Pos[0][1])) % 2
    for x, y in Pos:
        parity_current = (abs(x) + abs(y)) % 2
        if parity != parity_current:
            return -1
        pos.append([x + y, x - y])

    d = []
    for i in range(30, -1, -1):
        d.append(1 << i)
    if parity % 2 == 0:
        d.append(1)
    ans.append(str(len(d)))
    ans.append(' '.join(list(map(str, d))))

    for i in range(N):
        xdir, ydir = 0, 0
        xsum, ysum = 0, 0
        tmp = []
        for j in range(len(d)):
            if xsum <= pos[i][0]:
                xdir = 1
                xsum += d[j]
            else:
                xdir = -1
                xsum -= d[j]
            
            if ysum <= pos[i][1]:
                ydir = 1
                ysum += d[j]
            else:
                ydir = -1
                ysum -= d[j]
            
            if xdir == 1 and ydir==1:
                tmp.append('R')
            elif xdir == 1 and ydir==-1:
                tmp.append('U')
            elif xdir == -1 and ydir==-1:
                tmp.append('L')
            else:
                tmp.append('D')
        ans.append(''.join(tmp))
    ans = '\n'.join(ans)
    return ans

N = int(input())
Pos = [[int(i) for i in input().split()] for j in range(N)]
print(d_robot_arms(N, Pos))

Solution (Python):
import numpy as np
N = int(input())
P = []
Q = []
for i in range(N):
    P.append(list(map(int, input().split())))
    Q.append(sum(P[-1])%2)
if 1 in Q and 0 in Q:
    print(-1)
else:
    P = np.array(P)
    arm = [2**i for i in range(33)]
    if Q[0] == 0:
        arm.append(1)
    arm.reverse()
    print(len(arm))
    print(' '.join([str(n) for n in arm]))
    check2 = []
    for i in range(N):
        x = P[i, 0]
        y = P[i, 1]
        check = [[x, y]]
        STR = []
        for j in range(len(arm)):
            d = arm[j]
            if abs(x) > abs(y):
                if x > 0:
                    x = x-d
                    STR.append('R')
                else:
                    x = x+d
                    STR.append('L')
            else:
                if y > 0:
                    y = y-d
                    STR.append('U')
                else:
                    y = y+d
                    STR.append('D')
            check.append([x, y])
        if x == 0 and y == 0:
            check2.append('Yes')
        else:
            check2.append('No')

        print(''.join(STR))

Solution (Python):

def solve():
    D =  list(map((2).__pow__, range(31)[::-1]))
    wdict = {(True, True):('R',-1,-1), (True, False):('U',-1,1), (False, False):('L',1,1), (False, True):('D',1,-1)}
    mode = None
    for _ in [None]*int(input()):
        x, y = map(int, input().split())
        u = x+y
        if mode is None:
            mode = 1-u%2
            res = str(31+mode) + '\n' + ' '.join(map(str, [1]*mode+D))
            W0 = '\n'+'R'*mode
        elif mode != 1-u%2:
            return('-1')
        res += W0
        u -= mode
        v = x-y-mode
        for d in D:
            w, a, b = wdict[u>0, v>0]
            res += w
            u += a*d
            v += b*d
    return str(res)

if __name__ == '__main__':
    print(solve())

Solution (Python):

def solve():
    N = int(input())
    Z = [tuple(map(int, input().split())) for _ in [None]*N]
    p = set(z%2 for z in map(sum,Z))
    if len(p) == 2:
        res = '-1'
    else:
        res = ''
        mode, *_ = p
        mode = 1-mode
        D = [2**i for i in range(30,-1,-1)]
        res += str(31+mode)
        res += '\n' + ' '.join(str(d) for d in D+[1]*mode)
        wdict = {(True, True):('R', (1,0)), (True, False):('U', (0,1)), (False, False):('L',(-1,0)), (False, True):('D',(0,-1))}
        for x, y in Z:
            x -= mode
            W = '\n'
            for d in D:
                w, (a, b) = wdict[x+y>0, x-y>0]
                W += w
                x -= a*d
                y -= b*d
            W += 'R'*mode
            res += W
    return str(res)

if __name__ == '__main__':
    print(solve())

Solution (Python):
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

dist_max = 0
for i, (x, y) in enumerate(xy):
    dist = abs(x) + abs(y)
    if i == 0:
        parity = dist%2
    else:
        if dist%2 != parity:
            print(-1)
            exit()

    if parity == 0:
        x -= 1
        dist = abs(x) + abs(y)

    dist_max = max(dist_max, dist)
    xy[i] = [x, y]

d = []
d_i = 1
for i in range(40):
    if d_i > dist_max:
        break
    d.append(d_i)
    d_i *= 2
d = sorted(d, reverse = True)
if parity == 0:
    d.append(1)

print(len(d))
print(' '.join(map(str, d)))

for x, y in xy:
    ans = ''
    prev = 0
    for d_i in d:
        if prev == d_i and d_i == 1:
            ans += 'R'
            break
        if x+y < 0:
            if x-y < 0:
                ans += 'L'
                x += d_i
            else:
                ans += 'D'
                y += d_i
        else:
            if x-y < 0:
                ans += 'U'
                y -= d_i
            else:
                ans += 'R'
                x -= d_i
        prev = d_i
    print(ans)

Solution (Python):
def main():
    N = int(input())
    P = []
    distance_max = 0
    mode = 0

    for i in range(N):
        X, Y = map(int, input().split())
        distance = abs(X) + abs(Y)

        if i == 0:
            mode = distance % 2
        elif distance % 2 != mode:
            print(-1)
            return

        if mode == 0:
            X = X - 1
            distance = abs(X) + abs(Y)

        if distance > distance_max:
            distance_max = distance

        P.append((X, Y))

    d = []
    di = 1
    for i in range(40):
        if di > distance_max:
            break
        d.append(di)
        di = di * 2

    d.sort(reverse=True)

    if mode == 0:
        d.append(1)

    print(len(d))
    print(" ".join(map(str, d)))

    for p in P:
        path = ""
        x, y = p[0], p[1]
        previous = 0
        for di in d:
            if previous == di and di == 1:
                path = path + "R"
                break
            if x + y < 0:
                if x - y < 0:
                    path = path + "L"
                    x = x + di
                else:
                    path = path + "D"
                    y = y + di
            else:
                if x - y < 0:
                    path = path + "U"
                    y = y - di
                else:
                    path = path + "R"
                    x = x - di
            previous = di
        print(path)
    return

if __name__ == '__main__':
    main()