#include <bits/stdc++.h>
using namespace std;
long long n, m, k, x, b[205];
vector<pair<long long, long long>> v;
int main() {
  scanf("%lld %lld", &n, &m);
  long long cnt = 0;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld", &k);
    for (long long j = 1; j <= k; j++) {
      scanf("%lld", &x);
      b[x] = ++cnt;
    }
  }
  long long ind = 0, pos;
  for (long long i = 1; i <= cnt; i++) {
    for (long long j = 1; j <= n; j++) {
      if (b[j] == i) {
        pos = j;
        break;
      }
    }
    if (pos == i) continue;
    if (b[i] == 0) {
      v.push_back({pos, i});
      ind = pos;
      b[i] = b[pos], b[pos] = 0;
    } else {
      if (ind == 0) {
        for (long long j = 1; j <= n; j++) {
          if (b[j] == 0) {
            ind = j;
            break;
          }
        }
      }
      v.push_back({i, ind});
      v.push_back({pos, i});
      b[ind] = b[i], b[i] = b[pos], b[pos] = 0;
      ind = pos;
    }
  }
  long long size = v.size();
  printf("%lld\n", size);
  for (auto i : v) printf("%lld %lld\n", i.first, i.second);
}
