#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 200010;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(10); ++j) cin >> f[i][j];
  vector<vector<long long>> p(n, vector<long long>(11));
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(11); ++j) cin >> p[i][j];
  long long ans = -longinf;
  for (int i = (int)(0); i < (int)(1024); ++i) {
    long long res = 0;
    for (int j = (int)(0); j < (int)(n); ++j) {
      int cnt = 0;
      for (int k = (int)(0); k < (int)(10); ++k)
        if (f[j][k] == 1 && ((j >> k) & 1)) cnt++;
      res += p[j][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
