#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int f[110][10];
  int p[110][11];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 10; j++) cin >> f[i][j];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 11; j++) cin >> p[i][j];
  }
  int ans = -1000000000;
  for (long long mask = 1; mask < (1 << 10) - 1; mask++) {
    int res = 0;
    for (long long i = 0; i < n; i++) {
      int cnt = 0;
      for (long long j = 0; j < 10; j++) {
        if (mask & (1 << j) && f[i][j] == 1) {
          cnt++;
        }
      }
      res += p[i][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}
