#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> table(n);
  for (int i = 0; i < n; ++i) cin >> table[i];
  vector<pair<int, int> > numbers(3000, make_pair(-1, -1));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < table[i]; ++j) {
      int temp;
      cin >> temp;
      numbers[temp] = make_pair(i, j);
    }
  vector<pair<pair<int, int>, pair<int, int> > > change;
  pair<int, int> cur = make_pair(0, 0);
  for (int i = 0; i < 3000; ++i) {
    if (numbers[i].first == -1) continue;
    if (numbers[i] == cur) {
      ++cur.second;
      if (cur.second == table[cur.first]) {
        cur.second = 0;
        ++cur.first;
      }
      continue;
    }
    for (int j = i + 1; j < 3000; ++j)
      if (numbers[j] == cur) {
        change.push_back(make_pair(numbers[i], numbers[j]));
        numbers[j] = numbers[i];
        numbers[i] = cur;
        ++cur.second;
        if (cur.second == table[cur.first]) {
          cur.second = 0;
          ++cur.first;
        }
        break;
      }
  }
  cout << change.size() << endl;
  for (int i = 0; i < change.size(); ++i)
    cout << ++change[i].first.first << " " << ++change[i].first.second << " "
         << ++change[i].second.first << " " << ++change[i].second.second
         << endl;
}
