#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;


class Node {
	public:
        int value;
        Node* next;

        Node(int a) {
        	value = a;
            next = nullptr;
        }
};


class ForwardList {
	public:
		Node* head;
		Node* tail; // последний элемент
		
		ForwardList() {
			head = nullptr;
			tail = nullptr;
		}
		
		~ForwardList() {
			while (head != nullptr) pop_front();
		}

		void pop_front() {
			if (head == NULL) return;

			if (head == tail) {
				delete head;
				head = tail = nullptr;

				return;
			}

			Node* for_delete = head;
			head = for_delete->next;
			delete for_delete;
		}

		Node* get_at(int x) {
			if (x < 0) {return nullptr;}

			int n = 0;
			Node* pointer = head;

			while (n < x && pointer->next)
			{
				pointer = pointer->next;
				n++;
			}
			
			return (n == x) ? pointer : nullptr;
		}

		void push_at(int x, int y) {
			Node* previous = get_at(x);
			Node* current = get_at(x + 1);
			
			Node* new_node = new Node(y);

			if (previous) {
				previous->next = new_node;

				if (current) {new_node->next = current;}
			} 
			

			if (head == nullptr) {head = tail = new_node;}
			if (tail == nullptr) {tail = new_node;}
		}
		
		void pop_at(int x) {
			Node* previous = get_at(x - 1);
			Node* current = get_at(x);

			if (previous) {previous->next = current->next;}

			if (current) {
				if (head == current) {head == nullptr;}
				if (tail == current) {tail == nullptr;}
				delete current;
				
			}
		}

		
};


void execute_query(ForwardList& list, int type, int x, int y) {
	if (type == 1) {
		list.push_at(x, y);
	} else if (type == 2) {
		cout << list.get_at(x) << "\n";
	} else {
		list.pop_at(x);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	ForwardList FL;

	int q;
	cin >> q;
	

	for (int i = 0; i < q; i++) 
	{
		string query;
		getline(cin, query);


		int type = (int) (query[0] - '0');
		execute_query(
			FL,
			type,
			(int) (query[2] - '0'),
			(type == 1) ? ((int) (query[4] - '0')) : (0)
		);
	}

	return 0;
}