#include <bits/stdc++.h>
using namespace std;
int ntest = 0, test = 0;
inline void init();
inline void run();
inline void stop() { ntest = test - 1; }
int main() {
  init();
  while (++test <= ntest) {
    run();
  }
  return 0;
}
const int INF = (int)1E9 + 5;
const double EPS = 1E-11;
const long long MOD = (long long)1E9 + 7;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
inline void init() { ntest = 1; }
int n, m;
int whatPos[205], contain[205];
int step;
vector<pair<int, int> > ret;
inline int doMove(int what, int to) {
  int oldPos = whatPos[what];
  ret.push_back(make_pair(whatPos[what], to));
  step++;
  whatPos[what] = to;
  contain[to] = what;
  contain[oldPos] = 0;
  return oldPos;
}
inline void run() {
  scanf("%d%d", &n, &m);
  memset((contain), (0), sizeof(contain));
  int cnt = 0, t;
  for (int i = 0; i < (m); i++) {
    scanf("%d", &t);
    for (int j = 0; j < (t); j++) {
      cnt++;
      scanf("%d", &whatPos[cnt]);
      contain[whatPos[cnt]] = cnt;
    }
  }
  int w;
  for (int i = (1); i <= (n); i++) {
    if (contain[i] == 0) {
      w = i;
      break;
    }
  }
  step = 0;
  ret.clear();
  while (1) {
    if (w <= cnt) {
      w = doMove(w, w);
    } else {
      bool found = false;
      for (int i = (1); i <= (cnt); i++) {
        if (whatPos[i] != i && whatPos[i] <= cnt) {
          found = true;
          w = doMove(i, w);
          break;
        }
      }
      if (!found) {
        for (int i = (1); i <= (cnt); i++) {
          if (contain[i] == 0) {
            w = i;
            found = true;
            break;
          }
        }
      }
      if (!found) {
        break;
      }
    }
  }
  cout << ((int)(ret).size()) << endl;
  for (typeof((ret).begin()) it = (ret).begin(); it != (ret).end(); it++) {
    cout << it->first << " " << it->second << endl;
  }
}
