#include <bits/stdc++.h>
using namespace std;
int arr[222], n, m, t, tmp, s[222];
int getInd(int from) {
  int mn = 1 << 30, ret = -1;
  for (int i = from; i < n; i++)
    if (mn > arr[i]) {
      mn = arr[i];
      ret = i;
    }
  return ret;
}
int main() {
  cin >> n >> m;
  int k = 1;
  for (int i = 0; i <= n + 2; i++) {
    arr[i] = 1 << 30;
    s[i] = 1 << 30;
  }
  for (int i = 0; i < m; i++) {
    cin >> t;
    for (int j = 0; j < t; j++) {
      cin >> tmp;
      arr[tmp - 1] = k;
      s[tmp - 1] = k;
      k++;
    }
  }
  sort(s, s + n);
  int emp = -1;
  for (int i = 0; i < n; i++)
    if (arr[i] == (1 << 30)) {
      emp = i;
      break;
    }
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    if (s[i] != arr[i]) {
      if (arr[i] == (1 << 30)) {
        int ind = getInd(i + 1);
        emp = ind;
        v.push_back(make_pair(ind, i));
        swap(arr[i], arr[ind]);
      } else {
        v.push_back(make_pair(i, emp));
        swap(arr[emp], arr[i]);
        emp = i;
        int ind = getInd(i + 1);
        swap(arr[emp], arr[ind]);
        v.push_back(make_pair(ind, emp));
        emp = ind;
      }
    }
  }
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++)
    printf("%d %d\n", v[i].first + 1, v[i].second + 1);
}
