You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coordinates (0, 0). Also, let's mark the robot's current position as (x, y). In order to destroy all the bombs, the robot can perform three types of operations:  Operation has format "1 k dir". To perform the operation robot have to move in direction dir k (k ≥ 1) times. There are only 4 directions the robot can move in: "R", "L", "U", "D". During one move the robot can move from the current point to one of following points: (x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1) (corresponding to directions). It is forbidden to move from point (x, y), if at least one point on the path (besides the destination point) contains a bomb.  Operation has format "2". To perform the operation robot have to pick a bomb at point (x, y) and put it in a special container. Thus, the robot can carry the bomb from any point to any other point. The operation cannot be performed if point (x, y) has no bomb. It is forbidden to pick a bomb if the robot already has a bomb in its container.  Operation has format "3". To perform the operation robot have to take a bomb out of the container and destroy it. You are allowed to perform this operation only if the robot is at point (0, 0). It is forbidden to perform the operation if the container has no bomb. 

Help the robot and find the shortest possible sequence of operations he can perform to destroy all bombs on the coordinate plane.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of bombs on the coordinate plane. Next n lines contain two integers each. The i-th line contains numbers (x_{i}, y_{i}) ( - 10^9 ≤ x_{i}, y_{i} ≤ 10^9) — the coordinates of the i-th bomb. It is guaranteed that no two bombs are located at the same point and no bomb is at point (0, 0). 


-----Output-----

In a single line print a single integer k — the minimum number of operations needed to destroy all bombs. On the next lines print the descriptions of these k operations. If there are multiple sequences, you can print any of them. It is guaranteed that there is the solution where k ≤ 10^6.


-----Examples-----
Input
2
1 1
-1 -1

Output
12
1 1 R
1 1 U
2
1 1 L
1 1 D
3
1 1 L
1 1 D
2
1 1 R
1 1 U
3

Input
3
5 0
0 5
1 0

Output
12
1 1 R
2
1 1 L
3
1 5 R
2
1 5 L
3
1 5 U
2
1 5 D
3

Difficulty: interview

Starter code:

Solutions:
3

def readln(): return tuple(map(int, input().split()))

n, = readln()
ans = []
for x, y in sorted([readln() for _ in range(n)], key=lambda x: abs(x[0]) + abs(x[1])):
    if x > 0:
        ans.append('1 %d R' % x)
    if x < 0:
        ans.append('1 %d L' % -x)
    if y > 0:
        ans.append('1 %d U' % y)
    if y < 0:
        ans.append('1 %d D' % -y)
    ans.append('2')
    if x > 0:
        ans.append('1 %d L' % x)
    if x < 0:
        ans.append('1 %d R' % -x)
    if y > 0:
        ans.append('1 %d D' % y)
    if y < 0:
        ans.append('1 %d U' % -y)
    ans.append('3')
print(len(ans))
print('\n'.join(ans))


def f(i, j):
    x, y = str(abs(i)), str(abs(j))
    l, r, u, d = ' L', ' R', ' U', ' D'
    if i < 0: l, r = r, l
    if j < 0: u, d = d, u
    if i:
        if j: return ['1 ' + x + r, '1 ' + y + u, '2', '1 ' + x + l, '1 ' + y + d, '3']
        else: return ['1 ' + x + r, '2', '1 ' + x + l, '3']
    else: return ['1 ' + y + u, '2', '1 ' + y + d, '3']

p, n = [], int(input())
t = [(abs(i) + abs(j), i, j) for i, j in tuple(map(int, input().split()) for i in range(n))]
t.sort()
for r, i, j in t:
    p += f(i, j)
print(len(p))
print('\n'.join(p))

def f(i, j):
    x, y = str(abs(i)), str(abs(j))
    l, r, u, d = ' L', ' R', ' U', ' D'
    if i < 0: l, r = r, l
    if j < 0: u, d = d, u
    if i:
        if j: return ['1 ' + x + r, '1 ' + y + u, '2', '1 ' + x + l, '1 ' + y + d, '3']
        else: return ['1 ' + x + r, '2', '1 ' + x + l, '3']
    else: return ['1 ' + y + u, '2', '1 ' + y + d, '3']

p, n = [], int(input())
t = [(abs(i) + abs(j), i, j) for i, j in tuple(map(int, input().split()) for i in range(n))]
t.sort()
for r, i, j in t:
    p += f(i, j)
print(len(p))
print('\n'.join(p))

def f(i, j):

    x, y = str(abs(i)), str(abs(j))

    l, r, u, d = ' L', ' R', ' U', ' D'

    if i < 0: l, r = r, l

    if j < 0: u, d = d, u

    if i:

        if j: return ['1 ' + x + r, '1 ' + y + u, '2', '1 ' + x + l, '1 ' + y + d, '3']

        else: return ['1 ' + x + r, '2', '1 ' + x + l, '3']

    else: return ['1 ' + y + u, '2', '1 ' + y + d, '3']



p, n = [], int(input())

t = [(abs(i) + abs(j), i, j) for i, j in tuple(list(map(int, input().split())) for i in range(n))]

t.sort()

for r, i, j in t:

    p += f(i, j)

print(len(p))

print('\n'.join(p))



# Made By Mostafa_Khaled


from sys import stdin
input = stdin.readline
n = int(input())
seg = [list(map(int, input().split())) for _ in range(n)]
seg = sorted(seg, key=lambda x : abs(x[0]) + abs(x[1]))
res = []
for x, y in seg:
    if x > 0: res.append('1 %d %c' % (x, 'R'))
    if x < 0: res.append('1 %d %c' % (-x, 'L'))
    if y > 0: res.append('1 %d %c' % (y, 'U'))
    if y < 0: res.append('1 %d %c' % (-y, 'D'))
    res.append('2')
    if x > 0: res.append('1 %d %c' % (x, 'L'))
    if x < 0: res.append('1 %d %c' % (-x, 'R'))
    if y > 0: res.append('1 %d %c' % (y, 'D'))
    if y < 0: res.append('1 %d %c' % (-y, 'U'))
    res.append('3')    
print(len(res))
print('\n'.join(res))


import sys

def dist(p):
    return abs(p[0]) + abs(p[1])

n = int(input())

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

pts.sort(key=dist)

ops = []

def move(s, t, direc):
    if s == t: return
    if t > s: ops.append('1 {} {}'.format(t - s, direc[0]))
    else: ops.append('1 {} {}'.format(s - t, direc[1]))

for p in pts:
    move(0, p[0], 'RL')
    move(0, p[1], 'UD')
    ops.append('2')
    move(p[0], 0, 'RL')
    move(p[1], 0, 'UD')
    ops.append('3')

sys.stdout.write(str(len(ops))+'\n')
sys.stdout.write('\n'.join(ops))
    





n = int(input())
arr = [(abs(i) + abs(j), i, j) for i, j in tuple(list(map(int, input().split())) for i in range(n))]
arr.sort()
ans = []
for z, x, y in arr:
    X, Y = str(abs(x)), str(abs(y))
    l, r, u, d = ' L', ' R', ' U', ' D'
    if x < 0: l, r = r, l
    if y < 0: u, d = d, u
    if x:
        if y: ans += ['1 ' + X + r, '1 ' + Y + u, '2', '1 ' + X + l, '1 ' + Y + d, '3']
        else: ans += ['1 ' + X + r, '2', '1 ' + X + l, '3']
    else: ans += ['1 ' + Y + u, '2', '1 ' + Y + d, '3']
print(len(ans))
print('\n'.join(ans))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
#sys.setrecursionlimit(100000)


n=int(data())
A=[]
ans=[]
d=dd(list)
for i in range(n):
    x,y=mdata()
    A.append((x,y))
A.sort(key=lambda x:abs(x[0])+abs(x[1]))
for i in A:
    x,y=i
    if x > 0:
        ans.append('1 %d R' % x)
    elif x < 0:
        ans.append('1 %d L' % -x)
    if y > 0:
        ans.append('1 %d U' % y)
    elif y < 0:
        ans.append('1 %d D' % -y)
    ans.append('2')
    if x > 0:
        ans.append('1 %d L' % x)
    elif x < 0:
        ans.append('1 %d R' % -x)
    if y > 0:
        ans.append('1 %d D' % y)
    elif y < 0:
        ans.append('1 %d U' % -y)
    ans.append('3')
print(len(ans))
print('\n'.join(ans))




from sys import stdin, stdout

n = int(stdin.readline())
pos = []
for i in range(n):
    x, y = list(map( int,stdin.readline().split() ))
    pos.append([x,y])
pos = sorted( pos,key=lambda pos: abs(pos[0])+abs(pos[1]) )
# print(pos)
moves = []
for p in pos:
    x,y = p
    xNeg,yNeg=False,False
    xPos,yPos=False,False
    if x>0:
        # print("1 R ",x)
        moves.append( "1 {} R".format(x)  )
        xPos = True
    elif x<0:
        # print("1 L ",-x)
        moves.append( "1 {} L".format(-x)  )
        xNeg = True
    
    if y>0:
        # print("1 U ",y)
        moves.append( "1 {} U".format(y)  )
        yPos = True
    elif y<0:
        # print("1 D ",-y)
        moves.append( "1 {} D".format(-y)  )
        yNeg = True
    # print(2)
    moves.append( "{}".format(2)  )
    if xNeg:
        # print("1 R ",-x)
        moves.append( "1 {} R".format(-x)  )
    elif xPos:
        # print("1 L ",x)
        moves.append( "1 {} L".format(x)  )

    if yNeg:
        # print("1 U ",-y)
        moves.append( "1 {} U".format(-y)  )
    elif yPos:
        # print("1 D ",y)
        moves.append( "1 {} D".format(y)  )
    # print(3)
    moves.append( "{}".format(3)  )

print(len(moves))
for m in moves:
    stdout.write(m)
    stdout.write("\n")



import sys
from math import log2,floor,ceil,sqrt,gcd
# import bisect
# from collections import deque
# sys.setrecursionlimit(7*10**4)

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD =  1000000007
flag  = False

n = int(ri())
res=  []
qq = []
for i in range(n):
    x,y = Ri()
    qq.append([x,y])
qq.sort(key = lambda x : abs(x[0])+abs(x[1]))
for i in range(len(qq)):
    x,y = qq[i]
    if x > 0: res.append('1 %d %c' % (x, 'R'))
    if x < 0: res.append('1 %d %c' % (-x, 'L'))
    if y > 0: res.append('1 %d %c' % (y, 'U'))
    if y < 0: res.append('1 %d %c' % (-y, 'D'))
    res.append('2')
    if x > 0: res.append('1 %d %c' % (x, 'L'))
    if x < 0: res.append('1 %d %c' % (-x, 'R'))
    if y > 0: res.append('1 %d %c' % (y, 'D'))
    if y < 0: res.append('1 %d %c' % (-y, 'U'))
    res.append('3')
print(len(res))
print("\n".join(res))


import sys
input = lambda: sys.stdin.readline().strip("\r\n")


n = int(input())
ans = []
for x, y in sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: abs(x[0]) + abs(x[1])):
    if x > 0:
        ans.append('1 %d R' % x)
    if x < 0:
        ans.append('1 %d L' % -x)
    if y > 0:
        ans.append('1 %d U' % y)
    if y < 0:
        ans.append('1 %d D' % -y)
    ans.append('2')
    if x > 0:
        ans.append('1 %d L' % x)
    if x < 0:
        ans.append('1 %d R' % -x)
    if y > 0:
        ans.append('1 %d D' % y)
    if y < 0:
        ans.append('1 %d U' % -y)
    ans.append('3')
print(len(ans))
print('\n'.join(ans))


from sys import stdin, stdout
 
n = int(stdin.readline())
pos = []
for i in range(n):
    x, y = map( int,stdin.readline().split() )
    pos.append([x,y])
pos = sorted( pos,key=lambda pos: abs(pos[0])+abs(pos[1]) )
# print(pos)
moves = []
for p in pos:
    x,y = p
    xNeg,yNeg=False,False
    xPos,yPos=False,False
    if x>0:
        # print("1 R ",x)
        moves.append( "1 {} R".format(x)  )
        xPos = True
    elif x<0:
        # print("1 L ",-x)
        moves.append( "1 {} L".format(-x)  )
        xNeg = True
    
    if y>0:
        # print("1 U ",y)
        moves.append( "1 {} U".format(y)  )
        yPos = True
    elif y<0:
        # print("1 D ",-y)
        moves.append( "1 {} D".format(-y)  )
        yNeg = True
    # print(2)
    moves.append( "{}".format(2)  )
    if xNeg:
        # print("1 R ",-x)
        moves.append( "1 {} R".format(-x)  )
    elif xPos:
        # print("1 L ",x)
        moves.append( "1 {} L".format(x)  )
 
    if yNeg:
        # print("1 U ",-y)
        moves.append( "1 {} U".format(-y)  )
    elif yPos:
        # print("1 D ",y)
        moves.append( "1 {} D".format(y)  )
    # print(3)
    moves.append( "{}".format(3)  )
 
print(len(moves))
for m in moves:
    stdout.write(m)
    stdout.write("\n")

import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,=I()
seg = [I() for _ in range(n)]
seg = sorted(seg, key=lambda x : abs(x[0]) + abs(x[1]))
res = []
for x, y in seg:
    if x > 0: res.append('1 %d %c' % (x, 'R'))
    if x < 0: res.append('1 %d %c' % (-x, 'L'))
    if y > 0: res.append('1 %d %c' % (y, 'U'))
    if y < 0: res.append('1 %d %c' % (-y, 'D'))
    res.append('2')
    if x > 0: res.append('1 %d %c' % (x, 'L'))
    if x < 0: res.append('1 %d %c' % (-x, 'R'))
    if y > 0: res.append('1 %d %c' % (y, 'D'))
    if y < 0: res.append('1 %d %c' % (-y, 'U'))
    res.append('3')    
print(len(res))
print('\n'.join(res))


import sys
input = sys.stdin.readline
print = sys.stdout.write
I = lambda : list(map(int,input().split()))

n,=I()
l=[]
r=[];k=0
for i in range(n):
	x,y=I()
	if x<0:
		l.append([x,y])
	else:
		r.append([x,y])
	k = k+4 if x!=0 and y!=0 else k+2

k+=2*n;an=[]
l.sort(key=lambda x:abs(x[0])+abs(x[1]));r.sort(key=lambda x:abs(x[0])+abs(x[1]))
for i in range(len(r)):
	x,y=r[i]
	if x!=0:
		an.append("1 %d R"%x)
	if y!=0:
		an.append("1 %d %s"%(abs(y),("U" if y>0 else "D")))
	an.append('2')
	if x!=0:
		an.append("1 %d L"%x)
	if y!=0:
		an.append("1 %d %c"%(abs(y),('D' if y>0 else 'U')))
	an.append('3')

for i in range(len(l)):
	x,y=l[i]
	x=-x
	if x!=0:
		an.append("1 %d L"%x)
	if y!=0:
		an.append("1 %d %c"%(abs(y),('U' if y>0 else 'D')))
	an.append('2')
	if x!=0:
		an.append("1 %d R"%x)
	if y!=0:
		an.append("1 %d %c"%(abs(y),('D' if y>0 else 'U')))
	an.append('3')
print(str(k)+'\n')
print("\n".join(an))

n=int(input())
d=[]
for i in range(n):
    x,y=list(map(int,input().split()))
    d.append([(x**2+y**2)**(0.5),x,y])
d.sort()
ans=[]
for i in range(n):
    if d[i][1]<0:
        ans.append('1 '+str(-d[i][1])+' L')
    elif d[i][1]>0:
        ans.append('1 '+str(d[i][1])+' R')
    if d[i][2]<0:
        ans.append('1 '+str(-d[i][2])+' D')
    elif d[i][2]>0:
        ans.append('1 '+str(d[i][2])+' U')
    ans.append('2')
    if d[i][2]<0:
        ans.append('1 '+str(abs(d[i][2]))+' U')
    elif d[i][2]>0:
        ans.append('1 '+str(abs(d[i][2]))+' D')
    if d[i][1]<0:
        ans.append('1 '+str(abs(d[i][1]))+' R')
    elif d[i][1]>0:
        ans.append('1 '+str(abs(d[i][1]))+' L')
    ans.append('3')
print(len(ans))
print('\n'.join(ans))

import sys
input = sys.stdin.readline
n=int(input())
bombs=[]
for _ in range(n):
    x = list(map(int,input().split(' ')))
    bombs.append(x)
bombs.sort(key = lambda x: abs(x[0])+abs(x[1]))
out = []
for b in bombs:
    x = b
    get = []
    back = []
    if x[0] != 0:
        get.append('1 '+str(abs(x[0])) + ' ' + ('R' if x[0]>0 else 'L'))
        back.append('1 '+str(abs(x[0])) + ' ' + ('L' if x[0]>0 else 'R'))
    if x[1] != 0:
        get.append('1 '+str(abs(x[1])) + ' ' + ('U' if x[1]>0 else 'D'))
        back.append('1 '+str(abs(x[1])) + ' ' + ('D' if x[1]>0 else 'U'))
    out += get + ['2'] + back + ['3']
ss = ("\n".join([str(len(out))] + out))
sys.stdout.write(ss)


import sys
input = sys.stdin.readline
n=int(input())
bombs=[list(map(int, input().split(' '))) for _ in range(n)]
bombs.sort(key = lambda x: abs(x[0])+abs(x[1]))
out = []
for b in bombs:
    x = b
    get = []
    back = []
    if x[0] != 0:
        get.append('1 '+str(abs(x[0])) + ' ' + ('R' if x[0]>0 else 'L'))
        back.append('1 '+str(abs(x[0])) + ' ' + ('L' if x[0]>0 else 'R'))
    if x[1] != 0:
        get.append('1 '+str(abs(x[1])) + ' ' + ('U' if x[1]>0 else 'D'))
        back.append('1 '+str(abs(x[1])) + ' ' + ('D' if x[1]>0 else 'U'))
    out.extend(get + ['2'] + back + ['3'])
sys.stdout.write("\n".join([str(len(out))] + out))


import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
 
n,=I()
seg = [I() for _ in range(n)]
seg = sorted(seg, key=lambda x : abs(x[0]) + abs(x[1]))
res = []
for x, y in seg:
    if x > 0: res.append('1 %d %c' % (x, 'R'))
    if x < 0: res.append('1 %d %c' % (-x, 'L'))
    if y > 0: res.append('1 %d %c' % (y, 'U'))
    if y < 0: res.append('1 %d %c' % (-y, 'D'))
    res.append('2')
    if x > 0: res.append('1 %d %c' % (x, 'L'))
    if x < 0: res.append('1 %d %c' % (-x, 'R'))
    if y > 0: res.append('1 %d %c' % (y, 'D'))
    if y < 0: res.append('1 %d %c' % (-y, 'U'))
    res.append('3')    
print(len(res))
print('\n'.join(res))