#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const long long LINF = 1e18;
long long int n, cnt = 0, ans = 0, a[101][11], b[101][11], c, d, cmp[11],
                 cmpp[101], m, h, w, x, y, sum = 0, pos;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl = true;
struct edge {
  int to, cost;
};
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ans = INF * -1;
  for (long long int(i) = 0; (i) < (int)(n); (i)++)
    for (long long int(j) = 0; (j) < (int)(10); (j)++) cin >> a[i][j];
  for (long long int(i) = 0; (i) < (int)(n); (i)++)
    for (long long int(j) = 0; (j) < (int)(11); (j)++) cin >> b[i][j];
  for (int bit = 0; bit < (1 << 10); bit++) {
    for (long long int(i) = 0; (i) < (int)(10); (i)++) {
      if (bit & (1 << i)) {
        cmp[i] = 1;
      }
    }
    for (long long int(i) = 0; (i) < (int)(n); (i)++) {
      for (long long int(j) = 0; (j) < (int)(10); (j)++) {
        if (a[i][j] == 1 && cmp[j] == 1) cmpp[i]++;
      }
    }
    for (long long int(i) = 0; (i) < (int)(n); (i)++) {
      cnt += b[i][cmpp[i]];
    }
    ans = max(ans, cnt);
    for (long long int(i) = 0; (i) < (int)(10); (i)++) cmp[i] = 0;
    for (long long int(i) = 0; (i) < (int)(101); (i)++) cmp[i] = 0;
    cnt = 0;
    if (fl) ans = INF * -1, fl = false;
  }
  cout << (ans) << endl;
  return 0;
}
