#include <bits/stdc++.h>
using namespace std;
const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
  long long n;
  cin >> n;
  long long a[n];
  fill((long long*)a, (long long*)a + sizeof(a) / sizeof(long long), 0);
  for (int i = (0); i < ((n)); i++)
    for (int j = (0); j < ((10)); j++) {
      long long x;
      cin >> x;
      if (x == 1) a[i] += (1 << j);
    }
  long long p[n][11];
  for (int i = (0); i < ((n)); i++)
    for (int j = (0); j < ((11)); j++) {
      long long x;
      cin >> x;
      p[i][j] = x;
    }
  long long ans = -inf;
  for (int i = (1); i < (1 << 10); i++) {
    long long t = 0;
    for (int j = (0); j < ((n)); j++) {
      long long count = 0;
      for (int k = (0); k < ((10)); k++) {
        if ((i & (1 << k)) & (a[j] & (1 << k))) {
          count += 1;
        }
      }
      t += p[j][count];
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}
