#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second < b.second;
}
long long mod = 1e9 + 7;
int F[100][14];
int P[100][15];
signed main() {
  long long n, k, q, a;
  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 >> P[i][j];
  int res = -114514;
  for (int b = 1; b < (1 << 10); b++) {
    int cc = 0;
    for (long long i = 0; i < n; i++) {
      int c = 0;
      for (long long j = 0; j < 10; j++)
        if ((b >> j & 1) && F[i][j]) c++;
      cc += P[i][c];
    }
    res = max(res, cc);
  }
  cout << res << endl;
}
