#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};
int main() {
  int n;
  cin >> n;
  int f[105][11];
  long long int p[105][12];
  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];
  long long int mx = -1000000010;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> cnt(10, 0);
    for (int j = 0; j < (n); ++j) {
      for (int i = 0; i < (10); ++i) {
        if (bit & (1 << i) && f[j][i] == 1) {
          cnt[j]++;
        }
      }
    }
    long long int sum = 0;
    for (int i = 0; i < (n); ++i) sum += p[i][cnt[i]];
    mx = max(mx, sum);
  }
  cout << mx << endl;
  return 0;
}
