#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-10;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
inline T sq(T a) {
  return a * a;
}
const int MAX_N = 256;
int n, m;
int a[MAX_N];
int it;
vector<pair<int, int> > v;
int get(int x) {
  for (long long int i = (0); i < (long long int)(n); i++)
    if (a[i] == x) return i;
  assert(false);
}
void cpy(int x, int y) {
  if (x == y) return;
  swap(a[x], a[y]);
  v.emplace_back(x, y);
}
int main() {
  scanf("%d %d", &n, &m);
  for (long long int i = (0); i < (long long int)(m); i++) {
    int sz, x;
    scanf("%d", &sz);
    for (long long int j = (0); j < (long long int)(sz); j++) {
      scanf("%d", &x);
      x--;
      a[x] = ++it;
    }
  }
  for (long long int i = (0); i < (long long int)(it); i++) {
    if (a[i] != 0) cpy(i, get(0));
    cpy(get(i + 1), i);
  }
  printf("%lld\n", ((long long int)(v).size()));
  for (auto &w : v) printf("%d %d\n", w.first + 1, w.second + 1);
  return 0;
}
