read N: n32; // number of nodes assume 1 <= N <= 1_000; for u upto N { read D[u]: n32; // degree of u assume 0 <= D[u] <= N - 1; for i upto D[u] { read A[u][i]: n32; // adjacency list assume 0 <= A[u][i] <= N - 1; assume A[u][i] != u; // no self loops } } call find_cycle(N, D, A) -> L: n32; // length of cycle write L; for i upto L { call get_cycle_node(i) -> u: n32; // i-th node in the cycle write u; }