#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > cluster;
vector<pair<int, int> > solution;
int file[201];
int i, j, n, m;
void solve(int IC, int IF) {
  int sz = cluster[IF].size();
  for (i = IC; i < IC + sz; i++) {
    if (cluster[IF][i - IC] == i) continue;
    if (file[i] != -1) {
      for (j = i + 1; j < n; j++) {
        if (file[j] == -1) {
          solution.push_back(make_pair(i + 1, j + 1));
          for (int k = 0; k < cluster[file[i]].size(); k++)
            if (cluster[file[i]][k] == i) cluster[file[i]][k] = j;
          swap(file[i], file[j]);
          break;
        }
      }
    }
    solution.push_back(make_pair(cluster[IF][i - IC] + 1, i + 1));
    swap(file[i], file[cluster[IF][i - IC]]);
    cluster[IF][i - IC] = i;
  }
}
int main() {
  int x;
  for (i = 0; i < 201; i++) memset(file, -1, sizeof(file));
  cin >> n >> m;
  cluster.resize(m);
  for (i = 0; i < m; i++) {
    cin >> x;
    cluster[i].resize(x);
    for (j = 0; j < x; j++) {
      cin >> cluster[i][j];
      cluster[i][j]--;
      file[cluster[i][j]] = i;
    }
  }
  for (int IC = 0, IF = 0; IC < n && IF < m; IC += cluster[IF].size(), IF++) {
    solve(IC, IF);
  }
  cout << solution.size() << endl;
  for (i = 0; i < solution.size(); i++)
    cout << solution[i].first << " " << solution[i].second << endl;
  return 0;
}
