#include <bits/stdc++.h>
using namespace std;
int n;
int f[111][11];
int p[111][12];
int main() {
  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];
  int res = -INT_MAX / 3;
  for (long long S = (long long)(0); S < (long long)(1 << 10); S++) {
    if (S == 0) continue;
    int score = 0;
    for (long long i = (long long)(0); i < (long long)(n); i++) {
      int cnt = 0;
      for (long long j = (long long)(0); j < (long long)(10); j++) {
        if ((S >> j) & 1) {
          if (f[i][j]) cnt++;
        }
      }
      score += p[i][cnt];
    }
    res = (res > score ? res : score);
  }
  cout << res << endl;
  return 0;
}
