#include typedef long long LL; #define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; ++i) #define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; --i) template void in(Tp &x) { char ch = getchar(), f = 1; x = 0; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') f = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= f; } template bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);} template bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);} template Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;} template Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;} const int MAXN = 5000010; int n, fa[MAXN], f[MAXN], A[MAXN]; int find(int x) { int tmp = x; while (fa[tmp] != tmp) tmp = fa[tmp]; while (x != tmp) {int pa = fa[x]; fa[x] = tmp; x = pa;} return tmp; } int main() { in(n); FOR(i, 1, n) fa[i] = i, A[i] = 0; FOR(i, 1, n) { int tp, x; in(tp); in(x); if (tp == 1) { A[x] = 1; if (x < n && A[x + 1]) { int fx = find(x + 1); fa[x] = fx; } if (x > 1 && A[x - 1]) { int fx = find(x - 1); int fy = find(x); fa[fx] = fy; } } else { if (x == 1) { if (n >= 2 && A[2]) printf("%d\n", find(2) + 1); else puts("2"); } else if (A[1]) { int nxt = find(1); if (nxt == x - 1) { if (x + 1 <= n && A[x + 1]) printf("%d\n", find(x + 1) + 1); else printf("%d\n", x + 1); } else printf("%d\n", nxt + 1); } else puts("1"); } } return 0; }