This page is still under construction.

Parts of this page are still being built. What you see may change.

Vasya's graph

Time limit2sMemory limit256 MB

Summary
Given K forbidden node pairs and M edges offered in order, keep each edge only if it does not connect any forbidden pair, and report which edges are kept.
Level

Hard8 of 10

Topics
Union-find, Graph, DFS, Implementation
Solved
No attempts yet

Problem

Vasya has got a graph. The graph has NN nodes, but it has no edges yet. Vasya cares a lot about the future graph structure: he knows KK pairs of nodes {u_ju\_j, v_jv\_j}, such that if there is a path between these nodes in the graph, the irredeemable will happen to the graph. Vasya must prevent it at all costs.

Vasya has made a list of MM unoriented edges. Vasya will examine the edges in the preset order and he will surely put them into the graph, if possible. If adding another edge will cause the irredeemable, Vasya will simply discard such an edge. Your task is to find out which edges are good for the graph and which ones must end up in the trash.

Input

The first line of the input file contains three integers NN, KK and MM (1≤N≤1051 \leq N \leq 10^5, 0≤K,M≤1050 \leq K, M \leq 10^5).

It is followed by KK lines, with the ii-th line containing two integers u_iu\_i and v_iv\_i, the numbers of conflicting nodes, which should not have any edges between them (1≤u_i<v_i≤N1 \leq u\_i < v\_i \leq N). The conflicting node pairs are unique.

Next come MM lines with the ii-th line containing two integers u~_i\tilde u\_i and v~_i\tilde v\_i, the numbers of nodes of the edge which can be added to the graph (1≤u~_i<v~_i≤N1 \leq \tilde u\_i < \tilde v\_i \leq N). These edges are provided in the order of examination. Edges in the list are unique.

Output

The first line of the output file must contain the number of edges that Vasya can accomodate into the graph. The second line must contain space-separated numbers of edges in the ascending order.

Examples2

  1. Example 1

    Input
    3 1 3
    1 2
    1 2
    2 3
    1 3
    
    Expected output
    1
    2
    
  2. Example 2

    Input
    5 2 6
    1 2
    2 3
    1 3
    2 4
    3 4
    1 4
    4 5
    1 5
    
    Expected output
    3
    1 2 5