#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 3;
const int K = 20;
const int inf = (int)1e9 + 7;
int a[200][200];
int u[200];
int p[200];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int s = 0;
  memset(u, -1, sizeof u);
  for (int i = 0; i < m; ++i) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      scanf("%d", &a[i][j]);
      --a[i][j];
      u[a[i][j]] = s;
      ++s;
    }
  }
  vector<pair<int, int> > ans;
  for (;;) {
    int x = -1, t = -1;
    for (int i = 0; i < n; ++i) {
      if (u[i] != i && u[i] != -1) {
        x = i;
      }
      if (u[i] == -1) {
        t = i;
      }
    }
    if (x == -1) {
      break;
    }
    bool f = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (u[i] == -1 && u[j] == i) {
          u[j] = -1;
          u[i] = i;
          ans.push_back(make_pair(j + 1, i + 1));
          f = 1;
          break;
        }
      }
      if (f) {
        break;
      }
    }
    if (f) {
      continue;
    }
    ans.push_back(make_pair(x + 1, t + 1));
    u[t] = u[x];
    u[x] = -1;
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
