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;
int deg[4444], u[2222], v[2222], mark[2222];
struct R {
  int v, sek, c;
} e[100010];
int kom[4444], cur[4444], q[4444], du, my, dis[4444];
vector<int> ed[4444];
int cnt = 1;
void Ins(int a, int b, int c) {
  e[++cnt] = (R){b, kom[a], c};
  kom[a] = cnt;
}
void AE(int a, int b) {
  Ins(a, b, 1);
  Ins(b, a, 0);
}
inline int gmin(register int a, register int b) { return a < b ? a : b; }
int s, t;
int BFS() {
  memset(dis, 0, (t + 10) * sizeof(int));
  memcpy(cur, kom, (t + 10) * sizeof(int));
  for (dis[q[du = my = 1] = s] = 1; du <= my;) {
    int u = q[du++];
    for (int i = kom[u]; i; i = e[i].sek)
      if (e[i].c && !dis[e[i].v]) {
        dis[e[i].v] = dis[u] + 1;
        q[++my] = e[i].v;
      }
  }
  return dis[t] > 0;
}
int DFS(int u) {
  if (u == t) return 1;
  for (int& i = cur[u]; i; i = e[i].sek)
    if (e[i].c && dis[e[i].v] == dis[u] + 1 && DFS(e[i].v)) {
      e[i].c--;
      e[i ^ 1].c++;
      return 1;
    }
  return 0;
}
int Dinic() {
  int res = 0;
  for (; BFS();)
    for (; DFS(s);) res++;
  return res;
}
int main() {
  int n1, n2, m, n;
  scanf("%d%d%d", &n1, &n2, &m);
  n = n1 + n2;
  s = n + 1;
  t = n + 2;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u[i], &v[i]);
    v[i] += n1;
    deg[u[i]]++;
    deg[v[i]]++;
    AE(u[i], v[i]);
    ed[u[i]].push_back(i);
    ed[v[i]].push_back(i);
  }
  int now = 0, minDegree = m;
  for (int i = 1; i <= n; i++) minDegree = gmin(minDegree, deg[i]);
  puts("0");
  for (int d = 1; d <= minDegree; d++) {
    for (int i = 1; i <= n1; i++) AE(s, i);
    for (int i = n1 + 1; i <= n; i++) AE(i, t);
    now += Dinic();
    printf("%d ", n * d - now);
    for (int i = 1; i <= m; i++) mark[i] = 0;
    for (int i = 1; i <= n; i++) deg[i] = 0;
    for (int i = 2; i <= 2 * m; i += 2)
      if (!e[i].c)
        printf("%d ", i / 2), mark[i / 2] = 1, deg[u[i / 2]]++, deg[v[i / 2]]++;
    for (int i = 1; i <= n; i++)
      for (int j = 0; deg[i] < d; j++)
        if (!mark[ed[i][j]]) printf("%d ", ed[i][j]), deg[i]++;
    puts("");
  }
  return 0;
}