#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long N;
long long F[105][15];
long long P[105][15];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (long long i = (long long)0; i < (long long)N; i++)
    for (long long j = (long long)0; j < (long long)10; j++) cin >> F[i][j];
  for (long long i = (long long)0; i < (long long)N; i++)
    for (long long j = (long long)0; j < (long long)11; j++) cin >> P[i][j];
  long long joi = 1;
  long long ans = -20000000;
  while (joi <= 1023) {
    long long times = joi;
    long long open[10];
    for (long long i = (long long)0; i < (long long)10; i++) {
      if ((times % 2) == 1)
        open[i] = 1;
      else
        open[i] = 0;
      times /= 2;
    }
    long long same[100] = {0};
    long long ret = 0;
    for (long long i = (long long)0; i < (long long)N; i++) {
      for (long long j = (long long)0; j < (long long)10; j++) {
        if ((open[j] == 1) && (F[i][j] == 1)) {
          same[i]++;
        }
      }
      ret += P[i][same[i]];
    }
    ans = max(ans, ret);
    joi++;
  }
  cout << ans << endl;
  return 0;
}
