Problem: You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.

Let's call some subset of its edges <image> k-covering iff the graph <image> has each of its vertices incident to at least k edges. Minimal k-covering is such a k-covering that the size of the subset <image> is minimal possible.

Your task is to find minimal k-covering for each <image>, where minDegree is the minimal degree of any vertex in graph G.

Input

The first line contains three integers n1, n2 and m (1 ≤ n1, n2 ≤ 2000, 0 ≤ m ≤ 2000) — the number of vertices in the first part, the number of vertices in the second part and the number of edges, respectively.

The i-th of the next m lines contain two integers ui and vi (1 ≤ ui ≤ n1, 1 ≤ vi ≤ n2) — the description of the i-th edge, ui is the index of the vertex in the first part and vi is the index of the vertex in the second part.

Output

For each <image> print the subset of edges (minimal k-covering) in separate line.

The first integer cntk of the k-th line is the number of edges in minimal k-covering of the graph. Then cntk integers follow — original indices of the edges which belong to the minimal k-covering, these indices should be pairwise distinct. Edges are numbered 1 through m in order they are given in the input.

Examples

Input

3 3 7
1 2
2 3
1 3
3 2
3 3
2 1
2 1


Output

0 
3 3 7 4 
6 1 3 6 7 4 5 


Input

1 1 5
1 1
1 1
1 1
1 1
1 1


Output

0 
1 5 
2 4 5 
3 3 4 5 
4 2 3 4 5 
5 1 2 3 4 5 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 12005;
int n, n1, m, x[N], y[N], freq[N], k = 1e9, rem, last[N], p[N], q[N], l, r;
struct edge {
  int u, v, c, last;
} e[N];
void addEdge(int u, int v, int c) {
  e[rem].u = u;
  e[rem].v = v;
  e[rem].c = c;
  e[rem].last = last[u];
  last[u] = rem++;
  e[rem].u = v;
  e[rem].v = u;
  e[rem].c = 0;
  e[rem].last = last[v];
  last[v] = rem++;
}
bool getPath() {
  memset(p, -1, sizeof p);
  p[0] = 0;
  l = r = 0;
  for (; l <= r; l++)
    for (int cur = last[q[l]]; cur != -1; cur = e[cur].last)
      if (e[cur].c && p[e[cur].v] == -1) p[e[cur].v] = cur, q[++r] = e[cur].v;
  return p[N - 1] != -1;
}
void MaxFlow() {
  int flow = 0;
  while (getPath()) {
    int mn = 1e9;
    for (int cur = N - 1; cur; cur = e[p[cur]].u) mn = min(mn, e[p[cur]].c);
    for (int cur = N - 1; cur; cur = e[p[cur]].u)
      e[p[cur]].c -= mn, e[p[cur] ^ 1].c += mn;
    flow += mn;
  }
}
vector<int> ans[N];
int main() {
  scanf("%d%d%d", &n, &n1, &m);
  memset(last, -1, sizeof last);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", x + i, y + i);
    y[i] += n;
    freq[x[i]]++;
    freq[y[i]]++;
  }
  for (int i = 1; i <= n + n1; i++) k = min(k, freq[i]);
  for (int i = 1; i <= n; i++) addEdge(0, i, freq[i] - k);
  for (int i = 0; i < m; i++) addEdge(x[i], y[i], 1);
  for (int i = n + 1; i <= n + n1; i++) addEdge(i, N - 1, freq[i] - k);
  for (int k = ::k; k > -1; k--) {
    MaxFlow();
    for (int i = 2 * n; i < 2 * n + 2 * m; i += 2)
      if (e[i].c) ans[k].push_back(i / 2 - n);
    for (int i = 0; i < 2 * n; i += 2) e[i].c++;
    for (int i = 2 * n + 2 * m; i < 2 * n + 2 * m + 2 * n1; i += 2) e[i].c++;
  }
  for (int i = 0; i <= k; i++) {
    printf("%d ", ans[i].size());
    for (auto j : ans[i]) printf("%d ", j + 1);
    puts("");
  }
}