#include <bits/stdc++.h>
using namespace std;
bool arr[202];
int main() {
  memset(arr, 0, sizeof(arr));
  int n, m;
  scanf("%d%d", &n, &m);
  set<int> space;
  vector<vector<int> > v(m);
  vector<pair<int, int> > res;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int temp;
      cin >> temp;
      arr[temp] = 1;
      v[i].push_back(temp);
    }
  }
  for (int i = 1; i <= n; i++)
    if (!arr[i]) space.insert(i);
  int target = 1;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j] != target) {
        int x = *space.begin();
        if (x == target) {
          space.erase(space.begin());
          res.push_back(pair<int, int>(v[i][j], x));
          space.insert(v[i][j]);
          v[i][j] = x;
        } else {
          for (int ii = i; ii < v.size(); ii++) {
            for (int jj = 0; jj < v[ii].size(); jj++) {
              if (v[ii][jj] == target) {
                res.push_back(pair<int, int>(target, *space.begin()));
                v[ii][jj] = *space.begin();
                space.erase(space.begin());
                space.insert(target);
                res.push_back(pair<int, int>(v[i][j], *space.begin()));
                space.erase(space.begin());
                space.insert(v[i][j]);
                v[i][j] = target;
              }
            }
          }
        }
      }
      target++;
    }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first << " " << res[i].second << endl;
  return 0;
}
