#include #include #include #define ll long long using namespace std; template void read(T &x) { x = 0; char c = getchar(); int f = 0; for (; !isdigit(c); c = getchar()) f |= c == '-'; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ '0'); if (f) x = -x; } template void write(T x, char ed = '\n') { if (x < 0) putchar('-'), x = -x; static short st[30], tp; do st[++tp] = x % 10, x /= 10; while (x); while (tp) putchar(st[tp--] | '0'); putchar(ed); } const int N = 5000050; int n, f[N]; inline int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); } int main() { read(n); for (int i = 1;i <= n + 1; ++i) f[i] = i; for (int i = 1, op, x;i <= n; ++i) { read(op), read(x); if (op == 1) { if (f[x] == x) f[x] = x + 1; } else { int t = find(1); if (t == x) t = find(t + 1); write(t); } } return 0; }