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>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void JIZZ(string output = "") {
  cout << output;
  exit(0);
}
const long double PI = 3.14159265358979323846264338327950288;
const long double eps = 1e-13;
const long long mod = 1e9 + 7;
struct edge {
  int u, v, f;
};
vector<edge> edg;
vector<int> G[4020];
void ae(int u, int v, int f) {
  if (!f) return;
  ;
  ;
  G[u].push_back(edg.size());
  edg.push_back({u, v, f});
  G[v].push_back(edg.size());
  edg.push_back({v, u, 0});
}
int dep[4020], vv[4020];
bool bfs(int s, int t, int c) {
  queue<int> q;
  q.push(s);
  dep[s] = 0;
  vv[s] = c;
  while (q.size()) {
    int now = q.front();
    q.pop();
    for (int eid : G[now]) {
      edge &e = edg[eid];
      if (e.f > 0 && vv[e.v] != c) {
        vv[e.v] = c;
        q.push(e.v);
        dep[e.v] = dep[now] + 1;
      }
    }
  }
  return vv[t] == c;
}
int cur[4020];
int dfs(int now, int t, int fl) {
  ;
  ;
  if (fl == 0) return 0;
  if (t == now) return fl;
  int f = 0, df;
  for (int &i = cur[now]; i < G[now].size(); ++i) {
    edge &e = edg[G[now][i]];
    if (e.f && dep[e.v] == dep[now] + 1 && (df = dfs(e.v, t, min(fl, e.f)))) {
      f += df;
      fl -= df;
      e.f -= df;
      edg[G[now][i] ^ 1].f += df;
    }
  }
  return f;
}
int flow(int s, int t) {
  memset((vv), (0), sizeof(vv));
  int f = 0, c = 0;
  while (bfs(s, t, ++c)) {
    memset(cur, 0, sizeof(cur));
    f += dfs(s, t, 0x3f3f3f3f);
  };
  ;
  return f;
}
vector<pair<int, int> > gg;
int dega[2005], degb[2005];
stack<vector<int> > ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n1, n2, m;
  cin >> n1 >> n2 >> m;
  gg.resize(m);
  for (auto &i : gg) cin >> i.first >> i.second;
  for (auto &i : gg) ++dega[i.first], ++degb[i.second];
  for (int i = 1; i <= n1; ++i)
    ;
  ;
  for (int i = 1; i <= n2; ++i)
    ;
  ;
  for (auto &i : gg) ae(i.first, i.second + n1, 1);
  int mindeg = m;
  for (int i = 1; i <= n1; ++i) mindeg = min(mindeg, dega[i]);
  for (int i = 1; i <= n2; ++i) mindeg = min(mindeg, degb[i]);
  for (int i = 1; i <= n1; ++i) ae(0, i, dega[i] - mindeg);
  for (int i = 1; i <= n2; ++i) ae(i + n1, n1 + n2 + 1, degb[i] - mindeg);
  int totf = 0;
  for (int i = mindeg; i >= 0; --i) {
    if (0)
      for (auto &e : edg) cout << e.u << " " << e.v << " " << e.f << endl;
    totf += flow(0, n1 + n2 + 1);
    ;
    ;
    vector<int> tmp;
    tmp.push_back(m - totf);
    for (int i = 0; i < m * 2; i += 2) {
      if (edg[i].f) tmp.push_back((i >> 1) + 1);
    }
    ans.push(tmp);
    for (int i = 1; i <= n1; ++i) ae(0, i, 1);
    for (int i = 1; i <= n2; ++i) ae(i + n1, n1 + n2 + 1, 1);
  };
  ;
  while (ans.size()) {
    for (int i : ans.top()) cout << i << " ";
    ans.pop();
    cout << '\n';
  }
}