#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c, a, x = 1;
  cin >> n >> m;
  int arr[201] = {};
  vector<pair<int, int> > res;
  for (int i = 0; i < m; i++) {
    cin >> c;
    for (int j = 0; j < c; j++) {
      cin >> a;
      arr[a] = x;
      x++;
    }
  }
  int emp = n;
  for (int i = 1; i <= n; i++)
    if (arr[i] == 0) {
      emp = i;
      break;
    }
  int id = n;
  for (int i = 1; i < x; i++) {
    if (arr[i] != i) {
      for (int j = i + 1; j <= n; j++) {
        if (arr[j] == i) {
          id = j;
          break;
        }
      }
      if (i != emp) res.push_back(make_pair(i, emp));
      res.push_back(make_pair(id, i));
      arr[emp] = arr[i];
      arr[i] = i;
      emp = id;
    }
  }
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first << " " << res[i].second << '\n';
  return 0;
}
