#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 1e9;
const long long INF = 1LL << 30;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int> > c(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> c[i][j];
    }
  }
  long long ans = -INF;
  for (int bit = 1; bit < (1 << 10); bit++) {
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      long long cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (bit & (f[i][j] << j)) {
          cnt++;
        }
      }
      sum += c[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
