#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
int n, m;
int a[205], b[205];
int vis[205];
map<int, int> mp, mp1;
int k, x;
int main() {
  scanf("%d %d", &n, &m);
  int top = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      scanf("%d", &x);
      a[++top] = i;
      b[x] = top;
    }
  }
  vector<pair<int, int>> vv;
  for (int i = 1; i <= top; i++) {
    if (b[i] == i) continue;
    int pos1;
    for (int j = i; j <= n; j++) {
      if (b[j] == i) {
        pos1 = j;
        break;
      }
    }
    if (b[i] != 0) {
      int pos = i;
      for (int j = n; j >= 1; j--) {
        if (b[j] == 0) {
          pos = j;
          break;
        }
      }
      swap(b[pos], b[i]);
      swap(b[pos1], b[i]);
      vv.push_back({i, pos});
      vv.push_back({pos1, i});
    } else {
      swap(b[pos1], b[i]);
      vv.push_back({pos1, i});
    }
  }
  printf("%d\n", vv.size());
  for (int i = 0; i < vv.size(); i++)
    printf("%d %d\n", vv[i].first, vv[i].second);
  return 0;
}
