import java.util.ArrayList;
import java.util.Scanner;

public class lycanthropy_ak {

    static class Edge {
        int from, to;
        int id;

        Edge(int from, int to, int id) {
            this.from = from;
            this.to = to;
            this.id = id;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        ArrayList<Edge>[] g = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            Edge e = new Edge(a, b, i + 1);
            g[a].add(e);
        }

        Boolean[] win = new Boolean[n];
        for (int i = 0; i < n; i++) {
            if (g[i].size() == 0) {
                win[i] = true;
            }
        }
        win[n - 1] = false;
        for (int i = n - 1; i >= 0; i--) {
            if (win[i] == null) {
                int loseCnt = 0;
                for (Edge e : g[i]) {
                    if (!win[e.to]) {
                        loseCnt++;
                    }
                }
                win[i] = loseCnt <= k;
            }
        }

        if (!win[0]) {
            System.out.println("NO");
            System.out.flush();
            return;
        }

        int v = 0;
        do {
            ArrayList<Integer> eIds = new ArrayList<>();
            for (Edge e : g[v]) {
                if (!win[e.to]) {
                    eIds.add(e.id);
                }
            }
            System.out.print(eIds.size() + " ");
            for (int id : eIds) {
                System.out.println(id + " ");
            }
            System.out.println();
            System.out.flush();
            v = in.nextInt() - 1;
        } while (v != -2);
    }
}
