#include <bits/stdc++.h>
using namespace std;
const int maxn = 51;
struct node {
  int x, y;
  void input(int _x, int _y) {
    x = _x;
    y = _y;
  }
} blocks[maxn * maxn];
int n, c[maxn], group[maxn * maxn], s;
bool used[maxn * maxn];
void init() {
  int m, w;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= c[i]; j++) {
      scanf("%d", &w);
      blocks[w].input(i, j);
      group[++s] = w;
    }
}
int que[maxn * maxn];
int w1[maxn * maxn], w2[maxn * maxn], w3[maxn * maxn], w4[maxn * maxn], top;
void push(int q1, int q2, int q3, int q4) {
  top++;
  w1[top] = q1;
  w2[top] = q2;
  w3[top] = q3;
  w4[top] = q4;
}
void func(int x) {
  int head = 0;
  for (que[0] = x; group[x] != que[0]; x = group[x]) que[++head] = group[x];
  for (int i = 1; i <= head; i++) {
    push(blocks[que[i - 1]].x, blocks[que[i - 1]].y, blocks[que[i]].x,
         blocks[que[i]].y);
    swap(blocks[que[i]], blocks[que[i - 1]]);
  }
  for (int i = 0; i <= head; i++) used[que[i]] = true;
}
void work() {
  for (int i = 1; i <= s; i++)
    if (!used[i]) func(i);
  printf("%d\n", top);
  for (int i = 1; i <= top; i++)
    printf("%d %d %d %d\n", w1[i], w2[i], w3[i], w4[i]);
}
int main() {
  init();
  work();
  return 0;
}
