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