#include <bits/stdc++.h>
using namespace std;
int qread() {
  char c;
  int s = 0, f = 1;
  while ((c = getchar()) < '0' || c > '9') (c == '-') && (f = -1);
  do s = s * 10 + c - '0';
  while ((c = getchar()) >= '0' && c <= '9');
  return s * f;
}
int n, m, B;
int a[88], t[88][88], R[88], C[88];
bool co[88];
int f[42][2500 * 42], tr[42][2500 * 42];
struct Node {
  int a, b, c, d;
} ans[1000011];
int lans = 0;
struct BG {
  int mp[88][88], p[88], q[88], n;
  bool vis[88];
  void clear(int N) { n = N; }
  bool Pei(int x) {
    vis[x] = 1;
    for (int i = 1; i <= n; i++)
      if (mp[x][i] && !q[i]) {
        p[x] = i;
        q[i] = x;
        return 1;
      }
    for (int i = 1; i <= n; i++)
      if (mp[x][i] && q[i] && !vis[q[i]] && Pei(q[i])) {
        p[x] = i;
        q[i] = x;
        return 1;
      }
    return 0;
  }
  void pei(int x) {
    memset(vis, 0, sizeof(vis));
    Pei(x);
  }
} g;
int main() {
  n = qread();
  m = qread();
  B = qread();
  for (int i = 1; i <= m; i++) a[i] = qread();
  for (int i = 1, x; i <= n; i++) {
    x = qread();
    for (int j = 1, u, v; j <= x; j++) {
      u = qread();
      v = qread();
      t[i][u] = v;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) R[i] += t[i][j], C[j] += t[i][j];
  int T = 0, maxr = 0;
  for (int i = 1; i <= n; i++) maxr = max(maxr, R[i]);
  for (int j = 1; j <= m; j++) T = max(T, C[j]);
  T = max(T, maxr);
  while (B) {
    int id = 0;
    for (int j = 1; j <= m; j++)
      if (T == C[j] && co[j]) {
        id = -1;
        break;
      }
    if (id == -1) break;
    for (int j = 1; j <= m; j++)
      if (T == C[j]) {
        id = j;
        break;
      }
    if (!id) break;
    if (a[id] > B) break;
    int tot = T >> 1;
    for (int i = 1; i <= n; i++) {
      if (tot < t[i][id]) {
        t[i][id + m] = tot;
        t[i][id] -= tot;
        break;
      } else {
        tot -= t[i][id];
        t[i][id + m] = t[i][id];
        t[i][id] = 0;
      }
    }
    co[id] = 1;
    B -= a[id];
    C[id] = 0;
    for (int i = 1; i <= n; i++) C[id] += t[i][id];
    C[id + m] = 0;
    for (int i = 1; i <= n; i++) C[id + m] += t[i][id + m];
    T = 0;
    for (int j = 1; j <= m; j++) T = max(T, C[j]);
    T = max(T, maxr);
  }
  g.clear(n + m + m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m + m; j++)
      if (t[i][j]) g.mp[i][j] = g.mp[j + n][i + m + m] = t[i][j];
  for (int i = 1; i <= n; i++)
    if (R[i] < T) g.mp[i][i + m + m] = T - R[i];
  for (int j = 1; j <= m + m; j++)
    if (C[j] < T) g.mp[j + n][j] = T - C[j];
  printf("%d\n", T);
  for (int j = 1; j <= m; j++) printf("%d", co[j]);
  puts("");
  lans = 0;
  for (int i = 1; i <= n + m + m; i++) g.pei(i);
  while (T) {
    int tmp = 0x3f3f3f3f;
    for (int i = 1; i <= n + m + m; i++) tmp = min(tmp, g.mp[i][g.p[i]]);
    for (int i = 1; i <= n; i++)
      if (g.p[i] <= m + m)
        ans[++lans] =
            (Node){i, g.p[i] <= m ? g.p[i] : g.p[i] - m, T - tmp, tmp};
    for (int i = 1; i <= n + m + m; i++) g.mp[i][g.p[i]] -= tmp;
    for (int i = 1; i <= n + m + m; i++)
      if (g.mp[i][g.p[i]] == 0) {
        g.q[g.p[i]] = 0;
        g.p[i] = 0;
        g.pei(i);
      }
    T -= tmp;
  }
  printf("%d\n", lans);
  for (int i = 1; i <= lans; i++)
    printf("%d %d %d %d\n", ans[i].a, ans[i].b, ans[i].c, ans[i].d);
  return 0;
}
