#include <bits/stdc++.h>
using namespace std;
bool gt(long double a, long double b) { return a > b + 1e-9; }
const int MAXN = 256;
int n, m, pos;
pair<int, int> a[MAXN], b[MAXN];
int main() {
  ios::sync_with_stdio(false);
  for (register int i = (0); i < (int)(MAXN); ++i)
    a[i] = b[i] = pair<int, int>(-1, -1);
  cin >> n >> m;
  for (register int i = (0); i < (int)(m); ++i) {
    int q;
    cin >> q;
    for (register int j = (0); j < (int)(q); ++j) {
      b[pos++] = pair<int, int>(i, j);
      int x;
      cin >> x;
      a[x - 1] = pair<int, int>(i, j);
    }
  }
  vector<pair<int, int> > res;
  for (register int i = (0); i < (int)(n); ++i)
    if (a[i] != b[i]) {
      int neg = i;
      while (a[neg].first != -1) neg++;
      int who = i;
      while (a[who] != b[i]) who++;
      if (i != neg) {
        res.push_back(pair<int, int>(i, neg));
        swap(a[i], a[neg]);
      }
      if (who != i) {
        res.push_back(pair<int, int>(who, i));
        swap(a[who], a[i]);
      }
    }
  cout << ((int)(res).size()) << endl;
  for (register int i = (0); i < (int)(((int)(res).size())); ++i)
    cout << res[i].first + 1 << " " << res[i].second + 1 << endl;
  return 0;
}
