#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int iINF = 1e9;
int main() {
  long long n, F[101][11], pair<int, int>[101][11];
  cin >> n;
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (10); j++) cin >> F[i][j];
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (11); j++) cin >> pair<int, int>[i][j];
  long long ans = -100, bit = pow(2, 10);
  for (long long i = (1); i < (bit); i++) {
    long long tmp = 0;
    for (long long j = (0); j < (n); j++) {
      long long cnt = 0;
      for (long long k = (0); k < (10); k++)
        if (i & (1 << k) && F[j][k]) cnt++;
      tmp += pair<int, int>[j][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
