#include <bits/stdc++.h>
using namespace std;
int n, a, b;
const long long INF = 100000000001;
int main() {
  cin >> n;
  int f[101] = {};
  int p[101][11] = {};
  int f1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f1;
      if (f1 == 1) f[i] += (1 << j);
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int total = -1000000000;
  for (int i = 1; i < (1 << 10); ++i) {
    int r = 0;
    for (int j = 1; j < n + 1; j++) {
      int k = i & f[j];
      int t = 0;
      for (int h = 0; h < 10; h++) {
        if ((k >> h) & 1 == 1) t += 1;
      }
      r += p[j][k];
    }
    total = max(total, r);
  }
  cout << total << endl;
  return 0;
}
