#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, m = -1145141919, f[114][514], p[114][514];
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int t = 0; t < 10; t++) cin >> f[i][t];
  for (int i = 0; i < n; i++)
    for (int c = 0; c < 11; c++) cin >> p[i][c];
  for (int j = 0; j < 1024; j++) {
    int c[114] = {0};
    s = 0;
    for (int i = 0; i < n; i++) {
      for (int t = 0; t < 10; t++) {
        if ((j & 1 << t) && f[i][t]) c[i]++;
      }
      s += p[i][c[i]];
    }
    m = max(m, s);
  }
  cout << m << endl;
}
