#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 2000000000000000000ll;
const int INF = 1000000100;
const long long int MOD = 1e9 + 7;
int main() {
  int n;
  int f[n][10];
  int p[n][11];
  cin >> n;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (10); ++j) {
      cin >> f[i][j];
    }
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (11); ++j) {
      cin >> p[i][j];
    }
  int ans = -INF;
  for (int i = 0; i < (1 << 10); ++i) {
    if (i == 0) continue;
    int score = 0;
    vector<int> cnt(n, 0);
    for (int j = 0; j < (n); ++j) {
      for (int k = 0; k < (10); ++k) {
        if (i >> k & f[j][k]) cnt[j]++;
      }
    }
    for (int k = 0; k < (n); ++k) {
      score += p[k][cnt[k]];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
