#include <bits/stdc++.h>
using namespace std;
int n, m, a[70][70], b, c[20], id[20], R[50], C[30], ans, p[70], q[70], cnt;
bool vis[70];
struct node {
  int a, b, c, d;
} st[1000010];
bool dfs(int x) {
  for (int i = 1; i <= n + m; i++) {
    if (vis[i] || !a[x][i]) continue;
    vis[i] = 1;
    if (!q[i] || dfs(q[i])) return p[x] = i, q[i] = x, true;
  }
  return false;
}
void work(int x) {
  for (int i = 1; i <= n + m; i++) vis[i] = false;
  dfs(x);
}
bool cmp(int &x, int &y) { return C[x] == C[y] ? c[x] < c[y] : C[x] > C[y]; }
int main() {
  scanf("%d%d%d", &n, &m, &b);
  for (int i = 1; i <= m; i++) scanf("%d", &c[i]), id[i] = i;
  for (int i = 1, k, x, y; i <= n; i++) {
    scanf("%d", &k);
    while (k--) scanf("%d%d", &x, &y), a[i][x] = y, R[i] += y, C[x] += y;
  }
  sort(id + 1, id + m + 1, cmp);
  for (int i = 1; i <= m; i++)
    if (b >= c[id[i]]) b -= c[id[i]], c[id[i]] = 0;
  for (int i = 1; i <= m; i++)
    if (!c[i]) {
      C[i] = 0;
      for (int j = 1; j <= n; j++) {
        int v = a[j][i] >> 1, r = a[j][i] & 1, op = C[i] < C[i + m] ? i : i + m;
        a[j][i] = a[j][i + m] = v, C[i] += v, C[i + m] += v;
        a[j][op] += r, C[op] += r;
      }
    }
  m <<= 1;
  for (int i = 1; i <= n; i++) ans = max(ans, R[i]);
  for (int j = 1; j <= m; j++) ans = max(ans, C[j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) a[j + n][i + m] = a[i][j];
  for (int i = 1; i <= n; i++) a[i][m + i] = ans - R[i];
  for (int j = 1; j <= m; j++) a[n + j][j] = ans - C[j];
  printf("%d\n", ans);
  for (int i = 1; i <= n + m; i++) work(i);
  while (ans) {
    int sth = INT_MAX;
    for (int i = 1; i <= n + m; i++) sth = min(sth, a[i][p[i]]);
    for (int i = 1; i <= n; i++)
      if (p[i] <= m)
        st[++cnt] = (node){i, (p[i] - 1) % (m / 2) + 1, ans - sth, sth};
    ans -= sth;
    for (int i = 1; i <= n + m; i++) a[i][p[i]] -= sth;
    for (int i = 1; i <= n + m; i++)
      if (!a[i][p[i]]) q[p[i]] = 0, work(i);
  }
  for (int i = 1; i <= m / 2; i++) printf("%d", !c[i]);
  puts("");
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++)
    printf("%d %d %d %d\n", st[i].a, st[i].b, st[i].c, st[i].d);
}
