#include <bits/stdc++.h>
using namespace std;
const int oo = 1 << 20;
const double EPS = 1e-15;
const int MaxN = 205;
int N, M;
pair<int, int> C[MaxN];
int second[MaxN];
vector<pair<int, int> > sol;
int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++) C[i] = pair<int, int>(-1, -1);
  for (int i = 0; i < M; i++) {
    cin >> second[i];
    for (int j = 0, x; j < second[i]; j++) {
      cin >> x;
      C[x] = pair<int, int>(i, j);
    }
  }
  int current = 0, tot = 0;
  for (int i = 1; current < M && i <= N; i++) {
    if (C[i] != pair<int, int>(current, tot)) {
      int indexC;
      for (int j = i + 1; j <= N; j++)
        if (C[j] == pair<int, int>(current, tot)) indexC = j;
      if (C[i] == pair<int, int>(-1, -1)) {
        sol.push_back(pair<int, int>(indexC, i));
        swap(C[i], C[indexC]);
      } else {
        int indexE;
        for (int j = i + 1; j <= N; j++)
          if (C[j] == pair<int, int>(-1, -1)) indexE = j;
        swap(C[i], C[indexE]);
        swap(C[i], C[indexC]);
        sol.push_back(pair<int, int>(i, indexE));
        sol.push_back(pair<int, int>(indexC, i));
      }
    }
    if (++tot == second[current]) {
      tot = 0;
      current++;
    }
  }
  cout << sol.size() << endl;
  for (int i = 0; i < (int)sol.size(); i++)
    cout << sol[i].first << " " << sol[i].second << endl;
  return 0;
}
