#include <bits/stdc++.h>
using namespace std;
int n, k;
int disk[256];
vector<int> file[256];
vector<pair<int, int> > ans;
bitset<256> visit;
void move(int from, int to) {
  if (from == to) return;
  ans.push_back(make_pair(from, to));
  if (disk[from]) {
    for (int i = 0; i < (int)file[disk[from]].size(); i++) {
      if (file[disk[from]][i] == from) {
        file[disk[from]][i] = to;
      }
    }
  }
  swap(disk[to], disk[from]);
}
void doSwap(int now, int next) {
  if (now == next) return;
  int ptr = -1;
  for (int i = 1; i <= n; i++) {
    if (!disk[i]) {
      ptr = i;
      break;
    }
  }
  move(next, ptr);
  move(now, next);
  disk[now] = 0;
}
int main() {
  cin >> n >> k;
  srand(time(NULL));
  for (int i = 0; i < k; i++) {
    int t, a;
    cin >> t;
    for (int j = 0; j < t; j++) {
      cin >> a;
      disk[a] = i + 1;
      file[i + 1].push_back(a);
    }
  }
  int ptr = 1;
  for (int i = 1; i <= k; i++) {
    int now = i;
    for (int j = 0; j < (int)file[now].size(); j++) {
      doSwap(file[now][j], ptr);
      ptr++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second << endl;
  }
  return 0;
}
