#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, ans = -10000000;
  cin >> n;
  int f[100][10] = {};
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(10); ++j) cin >> f[i][j];
  int p[100][10] = {};
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(10); ++j) cin >> p[i][j];
  for (int i = 1; i < (1 << 10); i++) {
    vector<int> count(n);
    for (int b = 0; b < (int)(10); ++b) {
      if (i >> b & 1) {
        for (int k = 0; k < (int)(n); ++k) {
          if (f[k][b]) count[k]++;
        }
      }
    }
    int sum = 0;
    for (int l = 0; l < (int)(n); ++l) {
      int c = count[l];
      sum += p[l][c];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
