Harryxun/stf_run huggingface dataset:
import math
A, B, Q = map(int, input().split())

inf = math.inf

S = [-inf] + [int(input()) for _ in range(A)] + [inf]
T = [-inf] + [int(input()) for _ in range(B)] + [inf]
X = [int(input()) for _ in range(Q)]

def bsearch_sub(a, v, imin, imax):
	if imax < imin:
		return imax + 1
	else:
		imid = imin + (imax - imin) // 2
		if v < a[imid]:
			return bsearch_sub(a, v, imin, imid - 1)
		elif a[imid] <= v:
			return bsearch_sub(a, v, imid + 1, imax)

def bsearch(a, v):
	return bsearch_sub(a, v, 0, len(a) - 1)

#print(S)
#print(T)
#print()

for x in X:
	s, t = bsearch(S, x), bsearch(T, x)
	#print(s, t, x)
	s1, s2, t1, t2 = S[s - 1], S[s], T[t - 1], T[t]
	r = []
	for sv in [s1, s2]:
		for tv in [t1, t2]:
			r += [abs(x - sv) + abs(sv - tv)]
			r += [abs(x - tv) + abs(sv - tv)]
	print(min(r))


### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())

INF = 10 ** 11 + 1
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

"""
def bsr(a, v, lo=0, hi=None):
	if hi == None:
		hi = len(a) - 1
	if hi < lo:
		return lo
	mi = (lo + hi) // 2
	if v < a[mi]:
		return bsr(a, v, lo, mi - 1)
	else:
		return bsr(a, v, mi + 1, hi)
"""

def bsr(a, v):
	return bisect.bisect_right(a, v)

#print(S)
#print(T)
#print()

for x in X:
	sr = bsr(S, x)
	sl = sr - 1
	tr = bsr(T, x)
	tl = tr - 1
	#print(sr, sl, tr, tl)
	#print(S[sr], S[sl], T[tr], T[tl])
	cost = []
	for m in [S[sr], S[sl]]:
		for n in [T[tr], T[tl]]:
			cost += [abs(x - m) + abs(m - n), abs(x - n) + abs(m - n)]
	#print(sr, sl, tr, tl, cost)
	print(min(cost))
	#break
# import numpy as np;
# from numba import jit
# import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    N = int(input())
    A = map(int, input().split())
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for a in A:
    ans *= a
    if ans > 1000000000000000000:
            print(-1)
            quit()
print(ans)
import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        return
print("NO")

### FIXED CODE ###

import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        exit()
print("NO")
n=int(input())
a=[]
t=[]
t.append(1)
for i in range(n):
  a.append(input())

x=a[0]
while True:
  if x==2:
    print(len(t))
    exit()
  elif x in t:
    print(-1)
    exit()
  else:
    x=a[x-1]

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
ans=1
res=1
for i in range(n):
  if a[res-1]==2:
    print(ans)
    exit()
  else:
    ans+=1
    res=a[res-1]

print(-1)
x = input()
print(x**3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
L=list(map(int,input().split()))
print(L[3],L[1],L[2])


### FIXED CODE ###

x,y,z = map(int,input().split())
print(z,x,y)
import queue
h,w=list(map(int,input().split()))
a=[]
for i in range(h):
  a.append(input())

#a[たて][よこ]
ma=0
li=[[0]*w for _ in range(h)]
li2=[[True]*w for _ in range(h)]
#そのマスが何手目で黒くなるかを調べる
#隣に黒がなければ、上下左右の一番小さいserch+1
#隣に黒があれば、1
def search(i,j):
  li2[i][j]= False
  if li[i][j]!= 0:
    return li[i][j]
  u=9999
  d=9999
  r=9999
  l=9999
  if i-1>=0:
    if a[i-1][j]=="#":
      li[i][j]=1
      return 1
    elif li2[i-1][j]:
      u=search(i-1,j)
  if i+1<h:
    if a[i+1][j]=="#":
      li[i][j]=1
      return 1
    elif li2[i+1][j]:
      d=search(i+1,j)
  if j-1>=0:
    if a[i][j-1]=="#":
      li[i][j]=1
      return 1
    elif li2[i][j-1]:
      l=search(i,j-1)
  if j+1<w:
    if a[i][j+1]=="#":
      li[i][j]=1
      return 1
    elif li2[i][j+1]:
      r=search(i,j+1)
  li[i][j]=min(u,d,r,l)+1
  return min(u,d,r,l)+1

ans=0
for hi in range(h):
  for wi in range(w):
    if a[hi][wi]==".":
      li2=[[True]*w for _ in range(h)]
      tmp= search(hi,wi)
      if tmp>ans:
        ans=tmp
print(ans)

### FIXED CODE ###

import collections

h,w=list(map(int,input().split()))
a=[input() for _ in range(h)]
#a[h][w]
direction=[[-1,0],[1,0],[0,-1],[0,1]]
visited=[[-1]*w for _ in range(h)]
q=collections.deque()

#全ての黒マスをキューに入れる
for hi in range(h):
  for wi in range(w):
    if a[hi][wi]=="#":
      q.append([hi,wi])
      visited[hi][wi]=0

while len(q)>0:
  ch,cw=q.popleft()
  for d in direction:
    nh=ch+d[0]
    nw=cw+d[1]
    #端からはみでない、まだ見てない白マス
    if nh>=0 and nw>=0 and nh<h and nw<w and visited[nh][nw]==-1:
      q.append([nh,nw])
      visited[nh][nw]=visited[ch][cw]+1

ans=0
for hi in range(h):
  tmp=max(visited[hi])
  if tmp > ans:
    ans=tmp
print(ans)
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = 0
for val in range(n):
	if len(factorization(val)) == 8:
      ans +=1
print(ans)

### FIXED CODE ###

n = int(input()) + 1
ans = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for val in range(n):
    if len(make_divisors(val)) == 8 and val%2 != 0:
        ans += 1
print(ans)
import itertools
import sys
input = sys.input.readline()


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()


### FIXED CODE ###

import itertools


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()
n, x = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(x-a[0]))
    exit()
a.sort()
else:
    box = [a[i+1]-a[i] for i in range(n-1)]
    b = min(box)
    for i in range(1,b+1):
        for j in range(n-1):
            if box[j]%i:
                break
            if j == n-2:
                ans = i
    d = abs(x-a[0])
    if ans <= d:
        for i in range(1,ans+1):
            if d%i:
                continue
            else:
                temp = i
        print(temp)
    else:
        for i in range(1,d+1):
            if ans%i:
                continue
            else:
                temp = i
        print(temp)



### FIXED CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(abs(x-a[0]))
    exit()
else:
    a.append(x)
    a.sort()
    box = [a[i+1]-a[i] for i in range(n)]
    b = min(box)
    for i in range(1,b+1):
        for j in range(n-1):
            if box[j]%i:
                break
            if j == n-2:
                ans = i
    print(ans)
n=int(input())
p=[]
total=0
for i in range(n,0,-1):
    p.append(i)
p.reverse()
for i in range(1,n):
    total+=i%p[i]
print(total)



### FIXED CODE ###

a,b,x=map(int,input().split())
import math
ab=a*b
s=x/a
h=(ab-s)*2/a
if ab/2<=s:
    print(math.degrees(math.atan2(h,a)))
else:
    w=s*2/b
    print(math.degrees(math.atan2(b,w)))
a = list(map(int,input().split()))
x = [a[0]]
y = [a[1]]
a = []
b = []
c = 0
d = 0
while x[len(x)-1] < x[0] + 1:
    x.append(round(x[d] + 0.01,2))
    y.append(round(y[d] + 0.01,2))
    d += 1
for i in x:
    a.append(i/0.08)
for i in y:
    b.append(i/0.1)
a.extend(b)
c = round(min([z for z in set(a) if a.count(z) > 1]))
if c > 0:
    print(c)
else:
    print(-1)

### FIXED CODE ###

a = list(map(int,input().split()))
A = a[0]
B = a[1]
c = True
for x in range(10001):
    a = x * 0.08
    b = x * 0.1
    if A == int(a) and B == int(b):
        print(x)
        c = False
        break
if c:
    print(-1)
#105

N, K = map(int, input().rstrip().split()):
    if N%K == 0:
        print(0)
    else:
        print(1)

### FIXED CODE ###

#105

N, K = map(int, input().rstrip().split())
if N%K == 0:
    print(0)
else:
    print(1)
# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root) if i < 0]


n, m = map(int, input().split())

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
        uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)

### FIXED CODE ###

# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


n, m = map(int, input().split())

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
          uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)
a = int(input())
s = input()

if (a >= 3200):
  print s
else:
  print('red')


### FIXED CODE ###

a = int(input())
s = input()

if (a >= 3200):
  print(s)
else:
  print('red')
a,b,c,d=map(int,input().split())
e=a//d
f=c//b
x=a-e*d
y=c-f*b
if x==y==0:
  if f<=e:
    print('Yes')
  else:
    print('N0')
if x==0:
  if f+1<=e:
    print('YES')
  else:
    print('No')
if y==0:
  if f<=e+1:
    print('Yes')
  else:
    print('NO')
else:
  if f<=e:
    print('Yes')
  else:
    print('No')
  

### FIXED CODE ###

S,W=map(int,input().split())
if S<=W:
  print('unsafe')
else:
  print('safe')
N, K, X, Y = map(int, input().split())

if N <= K:
  print(N * X)
else:
  print(K * X + (N-K) * Y)

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
  print(N * X)
else:
  print(K * X + (N-K) * Y)
import sys
from collections import deque

def bfs(maze, visited):
    try:
        sy,sx=0,0
        gy,gx=H-1,W-1
        queue = deque([[sy, sx]])
        visited[sy][sx] = 0
        while queue:
            y, x = queue.popleft()
            if [y, x] == [gy, gx]:
                return visited[y][x]

            p=[]
            if x>0 : p.append([0,-1])
            if x<W-1: p.append([0,1])
            if y>0: p.append([-1,0])
            if y<H-1: p.append([1,0])
            for j, k in p:
                new_y, new_x = y+j, x+k
                if maze[new_y][new_x] == "." and \
                    visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
    except RuntimeError:
        return -1


H,W=map(int,input().split())
m=[input() for i in range(H)]

ans=0
for i in range(H):
    for j in range(W):
        if m[i][j]==".": ans+=1

visited=[[-1]*W for i in range(H)]
p=bfs(m,visited)
print(p if p==-1 else ans-p-1)

### FIXED CODE ###

import sys
from collections import deque

def bfs(maze, visited):
    try:
        sy,sx=0,0
        gy,gx=H-1,W-1
        queue = deque([[sy, sx]])
        visited[sy][sx] = 0
        while queue:
            y, x = queue.popleft()
            if [y, x] == [gy, gx]:
                return visited[y][x]

            p=[]
            if x>0 : p.append([0,-1])
            if x<W-1: p.append([0,1])
            if y>0: p.append([-1,0])
            if y<H-1: p.append([1,0])
            for j, k in p:
                new_y, new_x = y+j, x+k
                if maze[new_y][new_x] == "." and \
                    visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
        return -1

    except RuntimeError:
        print(-1)
        sys.exit()


H,W=map(int,input().split())
m=[input() for i in range(H)]

ans=0
for i in range(H):
    for j in range(W):
        if m[i][j]==".": ans+=1

visited=[[-1]*W for i in range(H)]
p=bfs(m,visited)
print( p if p==-1 else ans-p-1)
import math
n = input()
n = int(n)
summ=0
count = 0
if(n%2==1): print("0")
else:
    while(n/5>0):
        if(count==0): 
            n=str(n)
            n=n[0:len(n)-1]
            n=int(n)
            count+=1
        else: n=int(n/5)
        #print("n="+str(n))
        summ+=n
    print(summ)
#12499999999999996
#1000000000000000000
#100000000000000010
# 99999999999999990

### FIXED CODE ###

import math
n = input()
n = int(n)
summ=0
count = 0
if(n%2==1): print("0")
else:
    while(n/5>0):
        if(count==0): 
            n=str(n)
            n=n[0:len(n)-1]
            if(len(n)==0): break
            else: n=int(n) 
            count+=1
        else:
            n = n*2
            n=str(n)
            n=n[0:len(n)-1]
            if(len(n)==0): break
            else: n=int(n)            
        #print("n="+str(n))
        summ+=n
    print(summ)
#12499999999999996
#1000000000000000000
#100000000000000010
# 99999999999999990
N = int(input())
A = list(map(int, input().split()))

li = [0]*((N+1) >> 1)


def mod(b, x, n):
    acc = b
    for i in range(1, x):
        acc = (acc * b) % n
    return int(acc)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(mod(2, c, 10E9-7))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(mod(2, c, 10E9-7))



### FIXED CODE ###

a, op, b = input().split()

a = int(a)
b = int(b)

if op == "+":
  print(a+b)
else:
  print(a-b)
a,b=map(int, input)
print(-((-b+1)//(a-1)))

### FIXED CODE ###

a,b=map(int, input().split())
print(-((-b+1)//(a-1)))
n,k,x,y=map(int, input().split())
if n > k:
  print(int(k*x+(n-k)*y))
else:  
  print(int(n*x))

### FIXED CODE ###

n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
    sum=n*x
else:
    sum=k*x+(n-k)*y
print(sum)
N, C = map(int, input().split())
num = 10#**5+1
count = [0]*(num)
channel = [0]*num
for i in range(N):
    s, t, c = map(int, input().split())
    print(count)
    if channel[s]==c and channel[t-1]==c:
        count[s]+=1
        count[t-1]-=1
    elif channel[s]==c:#はじめ＝終わり
        count[s]+=1
        count[t]-=1
    elif channel[t-1]==c:
        count[t-1]-=1
        count[s-1]+=1
    else:
        count[s-1]+=1
        count[t]-=1
    channel[s-1]=c
    channel[t]=c
print(count)
for i in range(1, num):
    count[i]+=count[i-1]
print(max(count))

### FIXED CODE ###

T_max = 10**5
N, C = map(int, input().split())
channel = [[] for _ in range(C)]
time = [0]*(T_max+2)
for i in range(N):
    s, t, c = map(int, input().split())
    channel[c-1].append((s, t))
for c in channel:
    c.sort()
    if len(c)==0:
        continue
    time[c[0][0]]+=1
    for i in range(1, len(c)):
        if c[i-1] [1] != c[i][0]:
            time[c[i-1][1]+1] -= 1
            time[c[i][0]]+=1
    time[c[-1][1]+1]-=1
for i in range(1, T_max+1):
    time[i] = time[i-1]+time[i]
print(max(time))
import math
def circle(x):
    return pi**(2*x)
  
 x=R

### FIXED CODE ###

import math
n=int(input())
def func(n):
    return math.pi*n*2
print(func(n))
import numpy as np
import numba
from typing import List


def solver(N: int, S: int, A) -> int:
    dp = [[0] * (S+1) for _ in range(N+1)]

    dp[0][0] = 1
    MOD = 998244353
    for i in range(N):
        for j in range(S+1):
            dp[i+1][j] += 2 * dp[i][j]
            dp[i+1][j] %= MOD
            if j + A[i] <= S:
                dp[i+1][j+A[i]] += dp[i][j]
                dp[i+1][j+A[i]] %= MOD
    return dp[N][S]


def main():
    N, S = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    ans = solver(N, S, A)
    print(ans)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

### FIXED CODE ###

import numpy as np
import numba
from typing import List


@numba.jit
def solver(N: int, S: int, A: np.array) -> int:
    dp = np.zeros((N+1, S+1), dtype=np.int64)

    dp[0,0] = 1
    MOD = 998244353
    for i in range(N):
        for j in range(S+1):
            dp[i+1, j] += 2 * dp[i, j]
            dp[i+1, j] %= MOD
            if j + A[i] <= S:
                dp[i+1, j+A[i]] += dp[i, j]
                dp[i+1, j+A[i]] %= MOD
    return dp[N,S]


def main():
    N, S = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    ans = solver(N, S, np.array(A))
    print(ans)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()
import numpy as np
n = int(input())
jousi = list(map(int, input().split()))
a = np.zeros(n)
for i in jousi :
    a[jousi[i] -1] += 1
    print(int(a[jousi[i] - 1]))

### FIXED CODE ###

import numpy as np
n = int(input())
jousi = list(map(int, input().split()))
a = np.zeros(n)
for i in range(len(jousi)) :
    a[jousi[i] - 1] += 1
for i in range(len(a)):
    print(int(a[i]))
N = int(input())
A = []
B = 0
C = []
for i in range(N):
  A[i] = int(input())
for i in range(N):
  B += int(input())
for i in range(N-1):
  C[i] = int(input())
for i in range(N-1):
  if A[i] +1 == A[i+1]:
    B += C[i]
print(B)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    B.append(C[A[i]-1])
print(sum(B))
# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
    for j in range(i,N):    
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
        else:
            Dist[i][j] = j-i
for j in range(N-1):
    ans=[0]
    for i in range(N):
        ans+=Dist[i]
c = collections.Counter(ans)
for i in range(N-1):
    print(c[i+1])


### FIXED CODE ###

# -*- coding: utf-8 -*-
S= list(input())

if S[2]==S[3] and S[4]==S[5]:
    YorN="Yes"
else:
    YorN="No"
print(YorN)
n = int(input())
ab = [set(map(int, input().split())) for i in range(n-1)]
coloring = [0]*(n-1)
uc = [set() for _ in range(n)]

def f(x):
  for i in ab:
    if x in i:
      c = 1
      while c in uc[x-1]:
        c += 1
      y = sum(i)-x
      uc[x-1].add(c)
      uc[y-1].add(c)
      num = ab.index(i)
      coloring[num] = c
      ab[num] = set()
      f(y)
f(1)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)

def f(x, y, z):
  c = 0
  for i in ab2[x]:
    if i[0] != y:
      c += 1
      if c == z:
        c += 1
      coloring[i[1]] = c
      x1 = i[0]
      y1 = x
      z1 = c
      f(x1, y1, z1)

f(0, None, None)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])
s = sys.argv[1]
print s[:4] + ' ' + s[4:]

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = raw_input()
print s[:4] + ' ' + s[4:]
import fractions
n = int(input())
a = list(map(int, input()))
ans = a[0]
for i in range(n):
  ans = fractions.gcd(ans, a[i])
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(n):
  ans = fractions.gcd(ans, a[i])
print(ans)
N, Q = map(int, input().split())
S = input()
output = []
for i in range(Q):
	l, r = map(int, input().split())
	Slr = S[l - 1:r]
	output.append(Slr[l - 1:r].count('AC'))
for i in output:
	print(i)


### FIXED CODE ###

b = input()
if b == 'A':
	print('T')
if b == 'C':
	print('G')
if b == 'T':
	print('A')
if b == 'G':
	print('C')
# -*- coding: utf-8 -*-
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))
    print(N,Z,p)
    if len(p) == 2:
        res = '-1'
    elif 0 in p:
        res = '20\n' + ' '.join('1' for _ in range(20))
        for x,y in Z:
            w = ('R'*x if x > 0 else 'L'*-x) + ('U'*y if y > 0 else 'D'*-y) + ('LR'*10)[:(20-abs(x)-abs(y))]
            res += '\n'+w
    else:
        res = '21\n' + ' '.join('1' for _ in range(21))
        for x,y in Z:
            w = ('R'*x if x > 0 else 'L'*-x) + ('U'*y if y > 0 else 'D'*-y) + ('LR'*10)[:(21-abs(x)-abs(y))]
            res += '\n'+w

    return str(res)

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





### FIXED CODE ###

# -*- coding: utf-8 -*-
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())