#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, val;
} store[3000];
bool cmp(node a, node b) { return a.val < b.val; }
int arr[55][55], c[55], x[3000], y[3000];
queue<int> q1, q2, q3, q4;
int main() {
  int n, cnt = 0, sum = 0, tmp;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c[i]; j++) {
      x[cnt + 1] = i;
      y[cnt + 1] = j;
      scanf("%d", &arr[i][j]);
      store[cnt].val = arr[i][j];
      store[cnt].x = i;
      store[cnt].y = j;
      cnt++;
    }
    sum += c[i];
  }
  sort(store, store + sum, cmp);
  for (int i = 1; i <= sum; i++) {
    if (store[i - 1].x == x[i] && store[i - 1].y == y[i])
      continue;
    else {
      q1.push(store[i - 1].x);
      q2.push(store[i - 1].y);
      int v = arr[x[i]][y[i]];
      arr[x[i]][y[i]] = i;
      arr[store[i - 1].x][store[i - 1].y] = v;
      store[v - 1].x = store[i - 1].x;
      store[v - 1].y = store[i - 1].y;
      q3.push(x[i]);
      q4.push(y[i]);
    }
  }
  printf("%d\n", q1.size());
  while (!q1.empty()) {
    tmp = q1.front();
    q1.pop();
    printf("%d", tmp);
    tmp = q2.front();
    q2.pop();
    printf(" %d", tmp);
    tmp = q3.front();
    q3.pop();
    printf(" %d", tmp);
    tmp = q4.front();
    q4.pop();
    printf(" %d\n", tmp);
  }
  return 0;
}
