#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000000000LL;
const double EPS = 1e-9;
const long long mod = 1000000007ll;
const int maxn = 300500;
int f[105][12];
int p[105][12];
int c[105];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(10); ++j) scanf("%d", &f[i][j]);
  }
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(11); ++j) scanf("%d", &p[i][j]);
  }
  int ret = -999995000;
  for (int msk = 1; msk < (1 << 10); msk++) {
    int cur = 0;
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < (int)(10); ++j)
        if ((msk & (1 << j)) && f[i][j]) c[i]++;
    for (int i = 0; i < n; i++) cur += p[i][c[i]];
    ret = max(ret, cur);
  }
  printf("%d\n", ret);
}
