#include <bits/stdc++.h>
using namespace std;
vector<int> g[203];
struct cop {
  int x, y;
};
cop ans[403];
int coun;
bool used[203];
int main() {
  int n, m;
  cin >> n >> m;
  int i, j, jj;
  int x, y;
  int sum = 0;
  for (i = 0; i < m; i++) {
    cin >> x;
    g[i].resize(x);
    for (j = 0; j < x; j++) {
      cin >> y;
      g[i][j] = y - 1;
      used[y - 1] = true;
    }
    sum += x;
  }
  int free;
  for (i = 0; i < n; i++)
    if (!used[i]) free = i;
  int ind1, ind2;
  ind1 = 0;
  ind2 = 0;
  for (i = 0; i < sum; i++) {
    if (free == i) {
      free = g[ind1][ind2];
      ans[coun].x = g[ind1][ind2];
      g[ind1][ind2] = i;
      ans[coun++].y = i;
    } else {
      for (j = 0; j < m; j++) {
        for (jj = 0; jj < g[j].size(); jj++)
          if (g[j][jj] == i) break;
        if (jj != g[j].size()) break;
      }
      if (j == m) {
        free = g[ind1][ind2];
        ans[coun].x = g[ind1][ind2];
        g[ind1][ind2] = i;
        ans[coun++].y = i;
      } else if (j != ind1 || jj != ind2) {
        ans[coun].x = i;
        ans[coun++].y = free;
        g[j][jj] = free;
        free = i;
        ans[coun].x = g[ind1][ind2];
        ans[coun++].y = i;
        free = g[ind1][ind2];
        g[ind1][ind2] = i;
      }
    }
    ind2++;
    if (ind2 == g[ind1].size()) {
      ind2 = 0;
      ind1++;
    }
  }
  cout << coun << endl;
  for (i = 0; i < coun; i++)
    cout << ans[i].x + 1 << " " << ans[i].y + 1 << endl;
  return 0;
}
