#include <bits/stdc++.h>
int n;
int a[50];
int table[2501][2501];
int s = 0;
int x, y;
int next_x, next_y;
void initTable() {
  for (int i = 0; i < 2501; i++) {
    for (int j = 0; j < 2501; j++) {
      table[i][j] = -1;
    }
  }
}
void seach(int d) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (table[i][j] == d) {
        x = i + 1;
        y = j + 1;
        return;
      }
    }
  }
}
void nextCeil(int cx, int cy) {
  if (cx % 2 == 1) {
    next_x = cx + 1;
    next_y = cy;
    if (table[next_x - 1][next_y - 1] == -1) {
      next_x = cx;
      next_y = cy + 1;
      if (table[next_x - 1][next_y - 1] == -1) {
        next_x = cx + 2;
        next_y = 1;
      }
    }
  } else {
    next_x = cx - 1;
    next_y = cy + 1;
    if (table[next_x - 1][next_y - 1] == -1) {
      next_x = cx + 1;
      next_y = 1;
    }
  }
}
int main() {
  while (scanf("%d", &n) != EOF) {
    initTable();
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < a[i]; j++) {
        scanf("%d", &table[i][j]);
      }
    }
    s = 0;
    int counter = 0;
    int swap[2501][4];
    for (int i = 0; i < n; i++) {
      s += a[i];
    }
    next_x = 1, next_y = 1;
    for (int i = 1; i <= s; i++) {
      if (table[next_x - 1][next_y - 1] != i) {
        seach(i);
        int temp = table[next_x - 1][next_y - 1];
        table[next_x - 1][next_y - 1] = table[x - 1][y - 1];
        table[x - 1][y - 1] = temp;
        swap[counter][0] = next_x;
        swap[counter][1] = next_y;
        swap[counter][2] = x;
        swap[counter][3] = y;
        counter++;
      }
      if (i == s) {
        break;
      }
      nextCeil(next_x, next_y);
    }
    printf("%d\n", counter);
    for (int k = 0; k < counter; k++) {
      printf("%d %d %d %d\n", swap[k][0], swap[k][1], swap[k][2], swap[k][3]);
    }
  }
  return 0;
}
