#include <bits/stdc++.h>
using namespace std;
int n, imem;
long long int cnt, mx;
bool f[100][10];
int p[100][10], spcnt[100];
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long int lcm(long long int x, long long int y) {
  long long int g = gcd(x, y);
  return x / g * y;
}
int main() {
  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];
  mx = LLONG_MIN;
  for (int i = 1; i < (1 << 10); i++) {
    cnt = 0;
    for (int j = 0; j < n; j++) spcnt[j] = 0;
    imem = i;
    for (int j = 0; j < 10; j++) {
      if (imem % 2 == 1) {
        for (int k = 0; k < n; k++) {
          if (f[k][j]) spcnt[k]++;
        }
      }
      imem = imem >> 1;
    }
    for (int j = 0; j < n; j++) {
      cnt += p[j][spcnt[j]];
    }
    mx = max(mx, cnt);
  }
  cout << mx << endl;
  return 0;
}
