Problem: For a dynamic list $L$ of integers, perform a sequence of the following operations. $L$ has a special element called END at the end of the list and an element of $L$ is indicated by a cursor.

* insert($x$): Insert $x$ before the element indicated by the cursor. After this operation, the cursor points the inserted element.
* move($d$): Move the cursor to the end by $d$, if $d$ is positive. Move the cursor to the front by $d$, if $d$ is negative.
* erase(): Delete the element indicated by the cursor. After this operation, the cursor points the element next to the deleted element. In case there is no such element, the cursor should point END.



In the initial state, $L$ is empty and the cursor points END.

Constraints

* $1 \leq q \leq 500,000$
* The cursor indicates an element of $L$ or END during the operations
* Erase operation will not given when the cursor points END
* $-1,000,000,000 \leq x \leq 1,000,000,000$
* Moving distance of the cursor ($\sum{|d|}$) does not exceed 1,000,000
* $L$ is not empty after performing all operations

Input

The input is given in the following format.


$q$
$query_1$
$query_2$
:
$query_q$


Each query $query_i$ is given by


0 $x$


or


1 $d$


or


2


where the first digits 0, 1 and 2 represent insert, move and erase operations respectively.

Output

Print all elements of the list in order after performing given operations. Print an element in a line.

Example

Input

5
0 1
0 2
0 3
1 1
2


Output

3
1

Solution (in PYTHON3):

Solution:
from sys import stdin

class QueueNode(object):
	def __init__(self,data,next=None,prev=None):
		self.data = data
		self.next = next
		self.prev = prev

class LinkList(object):
	def __init__(self,head=None):
		self.head = head
		self.tail = head
		self.cur  = head

	def insert_q(self,data):
		node = QueueNode(data)

		if self.cur is None:
			self.head = node
			self.tail = node
			self.cur  = node
			return

		currentNode = self.cur
		preNode = currentNode.prev

		if currentNode.prev is None:
			currentNode.prev = node
			node.next = currentNode
			self.head = self.cur = node
		else:
			if self.tail is not None:
				currentNode.prev = node
				node.prev = preNode
				node.next = currentNode
				preNode.next = node
				self.cur = node
			else:
				currentNode.next = node
				node.prev = currentNode
				node.next = None
				self.cur = node
				self.tail = node


	def move_q(self,mv):
		currentNode = self.cur
		cnt = mv
		while cnt != 0:
			if mv < 0:#prev
				if currentNode.prev is None:
					self.head = self.cur = currentNode
					break
				else:
					currentNode = currentNode.prev
					self.cur = currentNode
					cnt += 1
			else:#next
				if currentNode.next is None:
					self.cur = currentNode
					break
				else:
					currentNode = currentNode.next
					self.cur = currentNode
					cnt -= 1


	#カレントを削除する
	def delete_q(self):
		currentNode = self.cur
		nexNode = currentNode.next
		preNode = currentNode.prev

		#自身の前がいない（=先頭）
		if preNode is None:
			nexNode.prev = None
			self.head = nexNode
			self.cur = nexNode
		#自身の後ろがいない（=末尾）
		elif nexNode is None:
			preNode.next = None
			self.tail = None
		else:
			preNode.next = currentNode.next
			nexNode.prev = currentNode.prev
			self.cur = currentNode.next

	#先頭を表示する
	def print_q(self):
		if self.head is not None:
			print(self.head.data)

	#全体表示（先頭から）
	def print_all(self):
		if self.head is not None:
			currentNode = self.head
			while currentNode.next is not None:
				print(currentNode.data)
				currentNode = currentNode.next

if __name__ == '__main__':

	loopnum = int(input())

	ll = LinkList()
	ll.insert_q("E")
	for i in range(loopnum):
		cmd = stdin.readline().strip().split()
		if cmd[0] == "0":
			t = int(cmd[1])
			ll.insert_q(t)
		elif cmd[0] == "1":
			t = int(cmd[1])
			ll.move_q(t)
		else:
			ll.delete_q()
	ll.print_all()