#include <bits/stdc++.h>
using namespace std;
const int N = 510031;
int n;
int f[200][200], ans, P[200][200];
int cnt[200];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  ans = -1e9;
  for (int mask = 0; mask < (1 << 10); mask++) {
    for (int i = 1; i <= n; i++) {
      cnt[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < 10; j++) {
        if (f[i][j] == 1 && (mask & (1 << j))) cnt[i]++;
      }
    }
    int score = 0;
    for (int i = 1; i <= n; i++) {
      score += P[i][cnt[i]];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
