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