#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
const int maxm = 10000 + 10;
const int mod = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
const double PI = acos(-1.0);
bool f[maxn][20];
int p[maxn][20];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      int x;
      scanf("%d", &x);
      if (x) f[i][j] = true;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  int ans = -INF;
  for (int sta = 1; sta < (1 << 10); sta++) {
    int k = sta;
    int cnt[20] = {0};
    for (int i = 0; i < 10; i++) {
      if (k & 1) {
        for (int j = 0; j < n; j++) {
          if (f[j][i]) cnt[j]++;
        }
      }
      k >>= 1;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
      res += p[i][cnt[i]];
    }
    ans = max(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}
