#include <bits/stdc++.h>
using namespace std;
const int nmax = 120;
int n, m, b, T;
int ram[nmax + 1];
int price[nmax + 1], cc[nmax + 1], cm[nmax + 1], adev[nmax + 1];
bool _copy[nmax + 1];
bool viz[nmax + 1];
int g[nmax + 1][nmax + 1];
int l[nmax + 1], r[nmax + 1];
struct str {
  int x, y, t1, t2;
  str() {}
  str(int _x, int _y, int _t1, int _t2) { x = _x, y = _y, t1 = _t1, t2 = _t2; }
};
vector<str> solution;
bool pair_up(int node) {
  if (viz[node]) return 0;
  viz[node] = 1;
  for (int i = 1; i <= n + m; ++i) {
    if (g[node][i] > 0 && l[i] == 0) {
      l[i] = node;
      r[node] = i;
      return 1;
    }
  }
  for (int i = 1; i <= n + m; ++i) {
    if (g[node][i] > 0 && pair_up(l[i]) == 1) {
      l[i] = node;
      r[node] = i;
      return 1;
    }
  }
  return 0;
}
void cuplaj() {
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  bool ok = 1;
  while (ok) {
    memset(viz, 0, sizeof(viz));
    ok = 0;
    for (int i = 1; i <= n + m; ++i) {
      if (r[i] == 0 && pair_up(i)) {
        ok = 1;
      }
    }
  }
}
void citire() {
  fscanf(stdin, "%d%d%d", &n, &m, &b);
  for (int i = 1; i <= m; ++i) fscanf(stdin, "%d", &price[i]);
  for (int i = 1; i <= n; ++i) {
    int nr;
    fscanf(stdin, "%d", &nr);
    int sum = 0;
    for (int j = 0; j < nr; ++j) {
      int x, t;
      fscanf(stdin, "%d%d", &x, &t);
      cc[i] += t;
      cm[x] += t;
      g[i][x] += t;
    }
  }
}
void fa_masini_virtuale() {
  for (int i = 1; i <= n; ++i) {
    for (int j = m + 1; j <= m + n; ++j) {
      if (cc[i] < T && cm[j] < T) {
        int x = min(T - cc[i], T - cm[j]);
        g[i][j] += x;
        cc[i] += x;
        cm[j] += x;
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    for (int i = n + 1; i <= m + n; ++i) {
      if (cc[i] < T && cm[j] < T) {
        int x = min(T - cc[i], T - cm[j]);
        g[i][j] += x;
        cc[i] += x;
        cm[j] += x;
      }
    }
  }
  for (int i = n + 1; i <= m + n; ++i) {
    for (int j = m + 1; j <= m + n; ++j) {
      if (cc[i] < T && cm[j] < T) {
        int x = min(T - cc[i], T - cm[j]);
        g[i][j] += x;
        cc[i] += x;
        cm[j] += x;
      }
    }
  }
}
int main() {
  citire();
  vector<pair<int, int>> ord(m + 1);
  for (int i = 1; i <= m; ++i) ord[i] = {-cm[i], i};
  sort(ord.begin() + 1, ord.begin() + m + 1);
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    int aux = cm[ord[i].second];
    if (b >= price[ord[i].second]) {
      aux = (aux + 1) / 2;
      _copy[ord[i].second] = 1;
      b -= price[ord[i].second];
    }
    ans = max(ans, aux);
  }
  for (int i = 1; i <= n; ++i) ans = max(ans, cc[i]);
  T = ans;
  fprintf(stdout, "%d\n", ans);
  for (int i = 1; i <= m; ++i) {
    fprintf(stdout, "%d", _copy[i]);
    adev[i] = i;
  }
  int minit = m;
  for (int i = 1; i <= minit; ++i) {
    if (_copy[i]) {
      ++m;
      adev[m] = i;
      cm[m] = (cm[i] + 1) / 2;
      cm[i] = cm[i] - cm[m];
      ram[i] = cm[i];
      for (int j = 1; j <= n; ++j) {
        int aux = min(g[j][i], ram[i]);
        g[j][m] = g[j][i] - aux;
        g[j][i] = aux;
        ram[i] -= aux;
      }
    }
  }
  fa_masini_virtuale();
  int timp = 0;
  while (1) {
    int costmin = 1 << 30;
    for (int i = 1; i <= n + m; ++i) {
      for (int j = 1; j <= n + m; ++j) {
        if (g[i][j] > 0 && g[i][j] < costmin) {
          costmin = g[i][j];
        }
      }
    }
    if (costmin == 1 << 30) break;
    cuplaj();
    for (int i = 1; i <= n; ++i) {
      if (r[i] <= m) {
        solution.push_back(str(i, adev[r[i]], timp, costmin));
      }
    }
    timp += costmin;
    for (int i = 1; i <= n + m; ++i) {
      g[i][r[i]] -= costmin;
    }
  }
  fprintf(stdout, "\n%d\n", (int)solution.size());
  for (auto i : solution)
    fprintf(stdout, "%d %d %d %d\n", i.x, i.y, i.t1, i.t2);
  return 0;
}
