#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10, 0));
  vector<vector<long long int> > p(n, vector<long long int>(11, 0));
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  long long int ans = -1 * 1e+8;
  for (int i = 1; i < 1024; i++) {
    int d[10];
    int t = 1;
    for (int j = 0; j < 10; j++) {
      d[j] = (i / t) % 2;
      t *= 2;
    }
    vector<int> cnt(n, 0);
    for (int j = 0; j < 10; j++) {
      if (d[j]) {
        for (int k = 0; k < n; k++) {
          if (f[k][j]) {
            cnt[k]++;
          }
        }
      }
    }
    long long int temp = 0;
    for (int j = 0; j < n; j++) {
      temp += p[j][cnt[j]];
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
