#include #include #include #include #include #include #include using namespace std; #define LL long long template void read (T &x) { x = 0; T f = 1; char ch = getchar (); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar (); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar (); } x *= f; } template void write (T x) { if (x < 0) { x = -x; putchar ('-'); } if (x < 10) { putchar (x + '0'); return; } write (x / 10); putchar (x % 10 + '0'); } template void print (T x, char ch) { write (x); putchar (ch); } template T Min (T x, T y) { return x < y ? x : y; } template T Max (T x, T y) { return x > y ? x : y; } template T Abs (T x) { return x > 0 ? x : -x; } const int Maxn = 5 * 1e6 + 5; int n; int fa[Maxn + 5]; bool vis[Maxn + 5]; void MakeSet () { for (int i = 1; i <= Maxn; i++) fa[i] = i; } int FindSet (int x) { if (fa[x] != x) fa[x] = FindSet (fa[x]); return fa[x]; } void UnionSet (int x, int y) { int u = FindSet (x), v = FindSet (y); if (u == v) return; fa[u] = v; } int main () { MakeSet (); read (n); for (int i = 1; i <= n; i++) { int op, x; read (op); read (x); if (op == 1) { vis[x] = 1; if (vis[FindSet (x - 1)] == 1) UnionSet (x - 1, x); if (vis[FindSet (x + 1)] == 1) UnionSet (x, x + 1); } else { bool tmp = vis[x]; vis[x] = 1; int p = FindSet (1); while (vis[p] == 1) p = FindSet (p + 1); vis[x] = tmp; print (p, '\n'); } } return 0; }