#include <bits/stdc++.h>
using namespace std;
int n;
int f[100][10];
int p[100][11];
int main(int argc, char** argv) {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  long res = -100000000;
  for (unsigned i = 1; i < 1024; i++) {
    long pr = 0;
    for (int j = 0; j < n; j++) {
      int c = 0;
      for (int k = 0; k < 10; k++)
        if (f[j][k] && i & 0b1 << k) c++;
      pr += p[j][c];
    }
    res = max(res, pr);
  }
  cout << res << endl;
}
