#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
long long mod = 1e9 + 7;
long long tmp[100][10], v[100][10], a[100], n;
long long popcnt(long long x) {
  long long ret = 0;
  while (x) {
    if (x & 1) ret++;
    x >>= 1;
  }
  return ret;
}
void disp(long long x) {
  for (long long i = 9; i >= 0; i--)
    printf("%lld", (long long)!!(x & (1 << i)));
  printf("\n");
}
long long dfs(long long bit, long long p) {
  if (p == 10) {
    if (bit == 0) return -inf;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      long long t = popcnt(a[i] & bit);
      sum += v[i][t];
    }
    return sum;
  }
  long long ans = -inf;
  ans = max(ans, dfs(bit * 2 + 1, p + 1));
  ans = max(ans, dfs(bit * 2, p + 1));
  return ans;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 10; j++) scanf("%lld", &tmp[i][j]);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 11; j++) scanf("%lld", &v[i][j]);
  for (long long i = 0; i < n; i++) {
    long long t = 0;
    for (long long j = 0; j < 10; j++) t = t * 2 + tmp[i][j];
    a[i] = t;
  }
  long long ans = dfs(0, 0);
  printf("%lld\n", ans);
  return 0;
}
