#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, nr, mem[205], x, cluster[205], ord;
vector<pair<int, int>> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 1; i <= m; ++i) {
    cin >> nr;
    for (j = 1; j <= nr; ++j) cin >> x, mem[x] = ++ord;
  }
  for (i = 1; i <= ord; ++i) {
    if (mem[i] == i) continue;
    if (!mem[i]) {
      for (j = i + 1; j <= n; ++j)
        if (mem[j] == i) {
          ans.push_back(make_pair(j, i));
          mem[i] = i;
          mem[j] = 0;
          break;
        }
    } else {
      for (j = i + 1; j <= n; ++j)
        if (!mem[j]) {
          ans.push_back(make_pair(i, j));
          mem[j] = mem[i];
          break;
        }
      for (j = i + 1; j <= n; ++j)
        if (mem[j] == i) {
          ans.push_back(make_pair(j, i));
          mem[i] = i;
          mem[j] = 0;
          break;
        }
    }
  }
  cout << ans.size() << '\n';
  for (auto it : ans) cout << it.first << ' ' << it.second << '\n';
  return 0;
}
