#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
int n, m;
int son[maxn];
bool isUsable[maxn], err[maxn], already[maxn], vis[maxn];
vector<pair<int, int>> ans;
bool Solve(bool can, int x) {
  if (vis[x] && can) {
    return false;
  }
  vis[x] = true;
  if (son[x] == x || son[x] == 0) {
    already[x] = true;
    vis[x] = false;
    return true;
  }
  if (!isUsable[son[x]]) {
    ans.push_back(make_pair(x, son[x]));
    isUsable[son[x]] = true;
    isUsable[x] = false;
    already[x] = true;
    vis[x] = false;
    return true;
  }
  if (Solve(can, son[x])) {
    if (!already[x]) {
      isUsable[son[x]] = true;
      isUsable[x] = false;
      ans.push_back(make_pair(x, son[x]));
    }
  } else {
    int pos = -1;
    for (int i = 1; i <= n; i++) {
      if (!isUsable[i] && !vis[i]) {
        pos = i;
        break;
      }
    }
    isUsable[x] = false;
    isUsable[pos] = true;
    ans.push_back(make_pair(x, pos));
    Solve(false, son[x]);
    isUsable[pos] = false;
    isUsable[son[x]] = true;
    ans.push_back(make_pair(pos, son[x]));
  }
  already[x] = true;
  vis[x] = false;
  return true;
}
int main() {
  cin >> n >> m;
  int cnt = 1;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 1; j <= k; j++) {
      int x;
      cin >> x;
      son[x] = cnt++;
      isUsable[x] = true;
      err[x] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (err[i] && !already[i]) {
      Solve(true, i);
    }
  }
  cout << (int)ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
