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: MEDIUM_HARD
Tags: Sorting

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
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))


from sys import stdin, stdout

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def mp():
	return map(int, inp().split())
n = iinp()
ml = []
for i in range(n):
	(x, y) = mp()
	ml.append((x, y))
ml.sort(key=lambda x: abs(x[0]) + abs(x[1]))
ansl = []
for (x, y) in ml:
	if x > 0:
		ansl.append('1 ' + str(x) + ' R')
	if x < 0:
		ansl.append('1 ' + str(-x) + ' L')
	if y > 0:
		ansl.append('1 ' + str(y) + ' U')
	if y < 0:
		ansl.append('1 ' + str(-y) + ' D')
	ansl.append('2')
	if x > 0:
		ansl.append('1 ' + str(x) + ' L')
	if x < 0:
		ansl.append('1 ' + str(-x) + ' R')
	if y > 0:
		ansl.append('1 ' + str(y) + ' D')
	if y < 0:
		ansl.append('1 ' + str(-y) + ' U')
	ansl.append('3')
out(len(ansl))
out('\n'.join(ansl))


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	pos = []
	for _ in range(n):
		(x, y) = map(int, input().split())
		pos.append([x, y])
	pos.sort(key=lambda x: (abs(x[0]), abs(x[1])))
	ans = []
	for i in range(n):
		(x, y) = pos[i]
		if x > 0:
			ans.append([1, x, 'R'])
		elif x < 0:
			ans.append([1, -x, 'L'])
		if y > 0:
			ans.append([1, y, 'U'])
		elif y < 0:
			ans.append([1, -y, 'D'])
		ans.append([2])
		if x > 0:
			ans.append([1, x, 'L'])
		elif x < 0:
			ans.append([1, -x, 'R'])
		if y > 0:
			ans.append([1, y, 'D'])
		elif y < 0:
			ans.append([1, -y, 'U'])
		ans.append([3])
	print(len(ans))
	for item in ans:
		print(*item)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from math import log2, floor, ceil, sqrt, gcd
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 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))


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]))
moves = []
for p in pos:
	(x, y) = p
	(xNeg, yNeg) = (False, False)
	(xPos, yPos) = (False, False)
	if x > 0:
		moves.append('1 {} R'.format(x))
		xPos = True
	elif x < 0:
		moves.append('1 {} L'.format(-x))
		xNeg = True
	if y > 0:
		moves.append('1 {} U'.format(y))
		yPos = True
	elif y < 0:
		moves.append('1 {} D'.format(-y))
		yNeg = True
	moves.append('{}'.format(2))
	if xNeg:
		moves.append('1 {} R'.format(-x))
	elif xPos:
		moves.append('1 {} L'.format(x))
	if yNeg:
		moves.append('1 {} U'.format(-y))
	elif yPos:
		moves.append('1 {} D'.format(y))
	moves.append('{}'.format(3))
print(len(moves))
for m in moves:
	stdout.write(m)
	stdout.write('\n')


n = int(input())
tot = 0
boombs = []
for _ in range(n):
	(x, y) = map(int, input().split())
	tot += 2 + (2 if x == 0 or y == 0 else 4)
	boombs.append((abs(x) + abs(y), x, y))
boombs.sort()
moves = ('LR', 'DU')
print(tot)
for boomb in boombs:
	ans = []
	(_, x, y) = map(int, boomb)
	if x:
		ans.append(f'1 {abs(x)} {moves[0][x > 0]}')
	if y:
		ans.append(f'1 {abs(y)} {moves[1][y > 0]}')
	ans.append('2')
	if x:
		ans.append('1 ' + str(abs(x)) + ' ' + moves[0][x < 0])
	if y:
		ans.append('1 ' + str(abs(y)) + ' ' + moves[1][y < 0])
	ans.append('3')
	print('\n'.join(ans))


import io
import os
import sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def printd(*args, **kwargs):
	print(*args, **kwargs)
	pass

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
n = oint()
p = []
for i in range(n):
	(x, y) = rint()
	p.append([x, y])
p.sort(key=lambda a: abs(a[0]) + abs(a[1]))
ans = []
for i in range(n):
	(x, y) = p[i]
	if x > 0:
		ans.append(str(1) + ' ' + str(x) + ' R')
	elif x < 0:
		ans.append(str(1) + ' ' + str(-x) + ' L')
	if y > 0:
		ans.append(str(1) + ' ' + str(y) + ' U')
	elif y < 0:
		ans.append(str(1) + ' ' + str(-y) + ' D')
	ans.append('2')
	if x > 0:
		ans.append(str(1) + ' ' + str(x) + ' L')
	elif x < 0:
		ans.append(str(1) + ' ' + str(-x) + ' R')
	if y > 0:
		ans.append(str(1) + ' ' + str(y) + ' D')
	elif y < 0:
		ans.append(str(1) + ' ' + str(-y) + ' U')
	ans.append('3')
print(len(ans))
for a in ans:
	print(a)


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))


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
ml = []
for i in range(n):
	(x, y) = mp()
	ml.append((x, y))
ml.sort(key=lambda x: abs(x[0]) + abs(x[1]))
ansl = []
for (x, y) in ml:
	if x > 0:
		ansl.append('1 ' + str(x) + ' R')
	if x < 0:
		ansl.append('1 ' + str(-x) + ' L')
	if y > 0:
		ansl.append('1 ' + str(y) + ' U')
	if y < 0:
		ansl.append('1 ' + str(-y) + ' D')
	ansl.append('2')
	if x > 0:
		ansl.append('1 ' + str(x) + ' L')
	if x < 0:
		ansl.append('1 ' + str(-x) + ' R')
	if y > 0:
		ansl.append('1 ' + str(y) + ' D')
	if y < 0:
		ansl.append('1 ' + str(-y) + ' U')
	ansl.append('3')
out(len(ansl))
out('\n'.join(ansl))


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))


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 dist(p):
	return abs(p[0]) + abs(p[1])
n = int(input())
points = []
for i in range(n):
	(x, y) = map(int, input().split())
	points.append((x, y))
points.sort(key=dist)
ans = []
for (x, y) in points:
	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))


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 heapq
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
print = sys.stdout.write
from sys import stdout
import sys
n = int(input())
bombs = []
for _ in range(n):
	x = list(map(int, input().split(' ')))
	bombs.append(x)
bombs = sorted(bombs, 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'))
	ll = get + ['2'] + back + ['3']
	for ele in ll:
		out.append(ele)
ss = '\n'.join([str(len(out))] + out)
print(ss)


import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	n = int(input())
	arr = []
	for i in range(n):
		(x, y) = map(int, input().split())
		arr.append([abs(x) + abs(y), x, y])
	arr.sort()
	ans = []
	for i in range(n):
		t1 = ''
		t2 = ''
		s = ''
		x = arr[i][1]
		y = arr[i][2]
		if x > 0:
			s = '1 ' + str(x) + ' R'
			t1 = '1 ' + str(x) + ' L'
			ans.append(s)
		if x < 0:
			s = '1 ' + str(-x) + ' L'
			t1 = '1 ' + str(-x) + ' R'
			ans.append(s)
		if y > 0:
			s = '1 ' + str(y) + ' U'
			t2 = '1 ' + str(y) + ' D'
			ans.append(s)
		if y < 0:
			s = '1 ' + str(-y) + ' D'
			t2 = '1 ' + str(-y) + ' U'
			ans.append(s)
		ans.append('2')
		if t1 != '':
			ans.append(t1)
		if t2 != '':
			ans.append(t2)
		ans.append('3')
	print(len(ans))
	for i in ans:
		print(i)
main()


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
n = int(input())
arr = []
for i in range(n):
	li = [int(x) for x in input().split()]
	li.append(abs(li[0]) + abs(li[1]))
	arr.append(li)
arr = sorted(arr, key=lambda x: x[2])
(cx, cy) = (0, 0)
count = 0
ans = []
for ele in arr:
	(x, y) = (ele[0], ele[1])
	if x != 0:
		temp = [1]
		if x > 0:
			temp.append(x)
			temp.append('R')
		else:
			temp.append(abs(x))
			temp.append('L')
		ans.append(temp)
	if y != 0:
		temp = [1]
		if y > 0:
			temp.append(y)
			temp.append('U')
		else:
			temp.append(abs(y))
			temp.append('D')
		ans.append(temp)
	ans.append([2])
	(cx, cy) = (x, y)
	if cx != 0:
		temp = [1]
		if cx > 0:
			temp.append(cx)
			temp.append('L')
		else:
			temp.append(abs(cx))
			temp.append('R')
		ans.append(temp)
	if cy != 0:
		temp = [1]
		if cy > 0:
			temp.append(cy)
			temp.append('D')
		else:
			temp.append(abs(cy))
			temp.append('U')
		ans.append(temp)
	ans.append([3])
print(len(ans))
for ele in ans:
	print(*ele)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
ans = []

def move(x1, y1, x2, y2):
	if x2 > x1:
		ans.append((1, x2 - x1, 'R'))
	elif x1 > x2:
		ans.append((1, x1 - x2, 'L'))
	if y2 > y1:
		ans.append((1, y2 - y1, 'U'))
	elif y1 > y2:
		ans.append((1, y1 - y2, 'D'))
p = []
n = Int()
for i in range(n):
	p.append(value())
p.sort(key=lambda x: (abs(x[0]), abs(x[1])))
for i in p:
	(x, y) = i
	move(0, 0, x, y)
	ans.append((2, ''))
	move(x, y, 0, 0)
	ans.append((3, ''))
print(len(ans))
for i in ans:
	print(*i)


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))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))
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))


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
bomb = []
for i in range(n):
	(x, y) = map(int, input().split())
	a = ((x ** 2 + y ** 2) ** 0.5, x, y)
	bomb.append(a)
bomb.sort()
c = 0
res = []
for i in range(n):
	if bomb[i][1] == 0:
		if bomb[i][2] > 0:
			res.append([1, abs(bomb[i][2]), 'U'])
			res.append([2])
			res.append([1, abs(bomb[i][2]), 'D'])
			res.append([3])
			c += 4
		else:
			res.append([1, abs(bomb[i][2]), 'D'])
			res.append([2])
			res.append([1, abs(bomb[i][2]), 'U'])
			res.append([3])
			c += 4
	elif bomb[i][2] == 0:
		if bomb[i][1] > 0:
			res.append([1, abs(bomb[i][1]), 'R'])
			res.append([2])
			res.append([1, abs(bomb[i][1]), 'L'])
			res.append([3])
			c += 4
		else:
			res.append([1, abs(bomb[i][1]), 'L'])
			res.append([2])
			res.append([1, abs(bomb[i][1]), 'R'])
			res.append([3])
			c += 4
	elif bomb[i][1] > 0 and bomb[i][2] > 0:
		res.append([1, abs(bomb[i][1]), 'R'])
		res.append([1, abs(bomb[i][2]), 'U'])
		res.append([2])
		res.append([1, abs(bomb[i][1]), 'L'])
		res.append([1, abs(bomb[i][2]), 'D'])
		res.append([3])
		c += 6
	elif bomb[i][1] > 0 and bomb[i][2] < 0:
		res.append([1, abs(bomb[i][1]), 'R'])
		res.append([1, abs(bomb[i][2]), 'D'])
		res.append([2])
		res.append([1, abs(bomb[i][1]), 'L'])
		res.append([1, abs(bomb[i][2]), 'U'])
		res.append([3])
		c += 6
	elif bomb[i][1] < 0 and bomb[i][2] < 0:
		res.append([1, abs(bomb[i][1]), 'L'])
		res.append([1, abs(bomb[i][2]), 'D'])
		res.append([2])
		res.append([1, abs(bomb[i][1]), 'R'])
		res.append([1, abs(bomb[i][2]), 'U'])
		res.append([3])
		c += 6
	else:
		res.append([1, abs(bomb[i][1]), 'L'])
		res.append([1, abs(bomb[i][2]), 'U'])
		res.append([2])
		res.append([1, abs(bomb[i][1]), 'R'])
		res.append([1, abs(bomb[i][2]), 'D'])
		res.append([3])
		c += 6
print(c)
for i in res:
	print(*i)


n = int(input())
arr = [(abs(i) + abs(j), i, j) for (i, j) in tuple((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))


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))


import sys
testcases = int(input())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
arr = []
count_zero = 0
for testcase in range(testcases):
	(x, y) = get_ints()
	arr.append((x, y))
	if x == 0:
		count_zero += 1
	if y == 0:
		count_zero += 1
arr.sort(key=lambda x: abs(x[0]) + abs(x[1]))
print(6 * testcases - 2 * count_zero)
for tup in arr:
	x = tup[0]
	y = tup[1]
	if x < 0:
		print('1 ' + str(abs(x)) + ' L')
	if x > 0:
		print('1 ' + str(x) + ' R')
	if y < 0:
		print('1 ' + str(abs(y)) + ' D')
	if y > 0:
		print('1 ' + str(abs(y)) + ' U')
	print('2')
	if x < 0:
		print('1 ' + str(abs(x)) + ' R')
	if x > 0:
		print('1 ' + str(x) + ' L')
	if y < 0:
		print('1 ' + str(abs(y)) + ' U')
	if y > 0:
		print('1 ' + str(y) + ' D')
	print('3')


import math
from collections import defaultdict
import os
import sys
from io import BytesIO, IOBase
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
slmii = lambda : sorted(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def main():
	n = ii()
	lst = []
	for i in range(n):
		(x, y) = mii()
		lst.append([x, y])
	ans = []
	lst.sort(key=lambda x: math.sqrt(x[0] ** 2 + x[1] ** 2))
	for i in range(n):
		(x, y) = (lst[i][0], lst[i][1])
		if x > 0:
			if y > 0:
				ans.append([1, x, 'R'])
				ans.append([1, y, 'U'])
				ans.append([2])
				ans.append([1, x, 'L'])
				ans.append([1, y, 'D'])
				ans.append([3])
			elif y < 0:
				ans.append([1, x, 'R'])
				ans.append([1, -y, 'D'])
				ans.append([2])
				ans.append([1, x, 'L'])
				ans.append([1, -y, 'U'])
				ans.append([3])
			else:
				ans.append([1, x, 'R'])
				ans.append([2])
				ans.append([1, x, 'L'])
				ans.append([3])
		elif x < 0:
			if y > 0:
				ans.append([1, -x, 'L'])
				ans.append([1, y, 'U'])
				ans.append([2])
				ans.append([1, -x, 'R'])
				ans.append([1, y, 'D'])
				ans.append([3])
			elif y < 0:
				ans.append([1, -x, 'L'])
				ans.append([1, -y, 'D'])
				ans.append([2])
				ans.append([1, -x, 'R'])
				ans.append([1, -y, 'U'])
				ans.append([3])
			else:
				ans.append([1, -x, 'L'])
				ans.append([2])
				ans.append([1, -x, 'R'])
				ans.append([3])
		elif y > 0:
			ans.append([1, y, 'U'])
			ans.append([2])
			ans.append([1, y, 'D'])
			ans.append([3])
		else:
			ans.append([1, -y, 'D'])
			ans.append([2])
			ans.append([1, -y, 'U'])
			ans.append([3])
	print(len(ans))
	for i in ans:
		print(*i)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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))