public void dfs2(int s) {
        int pos = 0;

        if (visited[s]) {
            System.err.println("ERROR:" + s + ", " + cnt[s]);
            System.exit(1);
        }
        stack[pos++] = s;
        visited[s] = true;
        while (pos > 0) {
            s = stack[--pos];
            ++cnt[s];
            if (cnt[s] > 1) {
                if (cnt[s] > 2) {
                    System.err.println("ERROR:" + s + ", " + cnt[s]);
                    System.out.println(stack[pos]);
                    System.exit(1);
                }
                order[cur_order] = s;
                ++cur_order;
                continue;
            }
            if (cnt[s] > 1) {
                System.err.println("ERROR:" + s + ", " + cnt[s]);
                System.exit(1);
            }
            stack[pos++] = s;
            for (int i = 0; i < g.v[s].length; ++i) {
                int t = g.v[s][i];
                if (!visited[t]) {
                    if (t == 429284) {
                        System.out.println("visit 429284");
                    }
                    visited[t] = true;
                    stack[pos++] = t;
                }
            }
        }
    }