#include <bits/stdc++.h>
using namespace std;
long long n, f[105][15], p[105][15], cnt, ans = -100000000, c;
signed main() {
  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];
  }
  for (long long i = 1; i < (1 << 10); i++) {
    cnt = 0;
    for (long long j = 0; j < n; j++) {
      c = 0;
      for (long long k = 0; k < 10; k++) {
        if ((i >> k & 1) && f[j][k]) c++;
      }
      cnt += p[j][c];
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
