#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int f[100][14];
int p[100][15];
int main() {
  int n;
  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 < 11; j++) cin >> p[i][j];
  }
  int res = -(1 << 30);
  for (int b = 0; b < (1 << 10); b++) {
    int tmp = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if ((b >> j & 1) && f[i][j]) c++;
      }
      tmp += p[i][c];
    }
    if (res < tmp) res = tmp;
  }
  cout << res << endl;
  return 0;
}
