text: First) First = a; g[a][b] = 1; g[b][a] = 2; int k, first; scanf("%d", &k); while (k--) { scanf("%d", &first); p[a][b].push_back(first); } p[b][a] = p[a][b]; reverse(p[b][a].begin(), p[b][a].end()); } for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) if (g[i][j] == 1 && isCan(i, j)) can[j][i] = can[i][j] = 1; for ((i) = (1); (i) <= (n); ++(i)) work(i, 1, f_After); for ((i) = (1); (i) <= (n); ++(i)) work(i, 2, f_Before); Dp1(f_Before, Before); for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) if (g[i][j] == 1 && can[i][j] == 1) work2(i, j); Dp2(f_After, After); for ((i) = (1); (i) <= (n); ++(i)) for ((j) = (1); (j) <= (n); ++(j)) if (g[i][j] == 1 && can[i][j] == 1) check(i, j); for ((i) = (1); (i) <= (2 * n); ++(i)) cout << ans[i] << endl; return 0; }