#include <bits/stdc++.h>
using namespace std;
bool used[210];
int belong[210];
int visited[210];
struct node {
  int a, b;
} op[(210 << 1)];
int opnum;
int main() {
  int N, M, i, nn, j, pt, empty, opnum;
  while (scanf("%d%d", &N, &M) != EOF) {
    memset(used, false, sizeof(used));
    pt = 0;
    opnum = 0;
    empty = 1;
    for (i = 0; i < M; i++) {
      scanf("%d", &nn);
      for (j = 0; j < nn; j++) {
        scanf("%d", &visited[++pt]);
        used[visited[pt]] = true;
        belong[visited[pt]] = pt;
      }
    }
    for (i = 1; i <= pt; i++) {
      if (visited[i] != i) {
        if (used[i] == true)
          for (empty = 1; empty <= N; empty++) {
            if (used[empty] == false) {
              used[empty] = true;
              used[visited[i]] = false;
              visited[belong[i]] = empty;
              belong[empty] = belong[i];
              op[++opnum].a = i;
              op[opnum].b = empty;
              op[++opnum].a = visited[i];
              op[opnum].b = i;
              belong[i] = i;
              visited[i] = i;
              break;
            }
          }
        else {
          used[i] = true;
          used[visited[i]] = false;
          op[++opnum].a = visited[i];
          op[opnum].b = i;
          belong[i] = i;
          visited[i] = i;
        }
      }
    }
    printf("%d\n", opnum);
    for (i = 1; i <= opnum; i++) printf("%d %d\n", op[i].a, op[i].b);
  }
  return 0;
}
