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;
vector<int> ans[2010];
int o = -1;
struct edge {
  int to, index, c;
  edge(int a = 0, int b = 0, int i = 0) : to(a), index(b), c(i) {}
};
edge e[6 * 2010];
int n1, n2, m, a, b, vec[2 * 2010], _next[6 * 2010], deg[2 * 2010];
void addedge(int b, int a, int c, int i) {
  e[++o] = edge(a, i, c);
  _next[o] = vec[b];
  vec[b] = o;
  e[++o] = edge(b, i, 0);
  _next[o] = vec[a];
  vec[a] = o;
}
int depth[2 * 2010], cur[2 * 2010], t, s;
queue<int> q;
int bfs() {
  memset(depth, 0, sizeof(depth));
  q.push(s);
  depth[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = vec[u]; i != -1; i = _next[i])
      if (!depth[e[i].to] && e[i].c > 0) {
        depth[e[i].to] = depth[u] + 1;
        q.push(e[i].to);
      }
  }
  return depth[t];
}
int dfs(int u, int remain) {
  if (u == t || remain == 0) return remain;
  int flow = 0;
  for (int &i = cur[u]; i != -1; i = _next[i])
    if (depth[e[i].to] == depth[u] + 1 && e[i].c > 0) {
      int di = dfs(e[i].to, min(remain, e[i].c));
      if (di > 0) {
        remain -= di;
        flow += di;
        e[i].c -= di;
        e[i ^ 1].c += di;
        if (remain == 0) return flow;
      }
    }
  return flow;
}
void solve() {
  s = 0;
  t = n1 + n2 + 1;
  while (bfs()) {
    for (int i = 0; i <= n1 + n2 + 1; i++) cur[i] = vec[i];
    while (dfs(s, 0x7fffffff))
      ;
  }
  return;
}
int main() {
  std::cin >> n1 >> n2 >> m;
  for (int i = 0; i < 2 * 2010; i++) vec[i] = -1;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    deg[a]++;
    deg[b + n1]++;
    addedge(a, b + n1, 1, i);
  }
  int k = 1 << 30;
  for (int i = 1; i <= n1 + n2; i++) k = min(k, deg[i]);
  for (int i = 1; i <= n1; i++) {
    addedge(0, i, deg[i] - k, m + i);
  }
  for (int i = 1; i <= n2; i++) {
    addedge(n1 + i, n1 + n2 + 1, deg[i + n1] - k, m + n1 + i);
  }
  for (int j = k; j != -1; j--) {
    solve();
    for (int i = 0; i < 2 * m; i += 2)
      if (e[i].c) ans[j].push_back(e[i].index);
    for (int i = 2 * m; i <= o; i += 2) {
      e[i].c++;
    }
  }
  for (int i = 0; i <= k; i++) {
    cout << ans[i].size() << " ";
    for (auto &j : ans[i]) cout << j << " ";
    cout << endl;
  }
  return 0;
}