#include <bits/stdc++.h>
using namespace std;
const int maxn = 300;
const int inf = 1e9;
int a[maxn];
vector<pair<int, int> > ans;
void Swap(int v, int u) {
  if (v == u) return;
  a[u] = a[v];
  a[v] = -1;
  ans.push_back(make_pair(v, u));
}
int main() {
  int n, m, cur = 0, k, x;
  scanf("%d%d", &n, &m);
  memset(a, -1, sizeof(a));
  for (int i = 0; i < m; i++) {
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &x);
      x--;
      a[x] = cur++;
      ;
    }
  }
  for (int i = 0; i < cur; i++) {
    int pos = -1;
    for (int j = 0; pos == -1 && j < n; j++)
      if (a[j] == -1) pos = j;
    Swap(i, pos);
    pos = -1;
    for (int j = 0; pos == -1 && j < n; j++)
      if (a[j] == i) pos = j;
    Swap(pos, i);
  }
  printf("%d\n", (int)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;
}
