#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
const double EPS = 1e-11;
int main() {
  int n;
  cin >> n;
  vector<int> f(n);
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(10); ++j) {
      int x;
      cin >> x;
      f[i] += (x << j);
    }
  }
  vector<vector<int> > p(n, vector<int>(11));
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(11); ++j) cin >> p[i][j];
  int ans = -1e9;
  for (int m = 0; m < (int)(1024); ++m) {
    int tmp = 0;
    for (int i = 0; i < (int)(n); ++i)
      tmp += p[i][__builtin_popcount(f[i] & m)];
    ans = max((ans), (tmp));
  }
  cout << ans << endl;
  return 0;
}
