#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
pair<int, int> a[210];
int k[210];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) a[i] = make_pair(-1, -1);
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < (int)(k[i]); j++) {
      int p;
      scanf("%d", &p);
      p--;
      a[p] = make_pair(i, j);
    }
  }
  int cur = 0;
  vector<pair<int, int> > ans;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(k[i]); j++) {
      int pos1 = int(find(a, a + n, make_pair(i, j)) - a);
      if (pos1 != cur) {
        int pos2 = int(find(a, a + n, make_pair(-1, -1)) - a);
        if (pos2 != cur) {
          ans.push_back(make_pair(cur, pos2));
          swap(a[cur], a[pos2]);
        }
        ans.push_back(make_pair(pos1, cur));
        swap(a[pos1], a[cur]);
      }
      cur++;
    }
  printf("%d\n", ans.size());
  for (int i = 0; i < (int)(ans.size()); i++)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
  return 0;
}
