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