#include <bits/stdc++.h>
using namespace std;
int a[20][20];
int p[20][20];
int q[1 << 10];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(10); ++j) cin >> a[i][j];
  }
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(11); ++j) cin >> p[i][j];
  }
  int ans = -1000000007;
  for (int bit = 0; bit < (int)(1 << 10); ++bit) {
    if (bit == 0) {
      continue;
    } else {
      vector<int> cnt(n);
      for (int j = 0; j < (int)(10); ++j) {
        if ((bit >> j) & 1) {
          for (int k = 0; k < (int)(n); ++k) {
            if (a[k][j] == 1) cnt[k]++;
          }
        }
      }
      int tmp = 0;
      for (int i = 0; i < (int)(n); ++i) {
        tmp += p[i][cnt[i]];
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}
