#include int globina (int * a, int * b) { int globina[2]; if (*a) globina[0] = globina(a+*a, b); if (*b) globina[1] = globina(a, b+*b); } int main (void) { int n; scanf("%d\n", &n); int a[n]; int b[n]; for (int i = 0; i < n; i++) scanf("%d %d\n", &a[i], &b[i]); printf("%d\n", globina(a, b)); }