/* -*- coding: utf-8 -*- * * 3086.cc: No.3086 Re One Two - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ /* global variables */ int as[MAX_N], bs[MAX_N]; int ps[MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i); fill(ps, ps + n, -1); for (int i = 0, j = 0; i < n; i++) { if (as[i] == 1) ps[i + 1] = i; else if (bs[i] == 2) { while (bs[j] != 1) j++; ps[j++] = i; } else { for (int u = i; u >= 0; u = ps[u]) printf("%d\n", u + 1); } } return 0; }