#include <bits/stdc++.h>
using namespace std;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  }
  vector<vector<int>> p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) scanf("%d", &p[i][j]);
  }
  long long ans = -INFL;
  for (int use = 1; use < (1 << 10); use++) {
    long long res = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (f[i][j] == 1 && use & (1 << j)) {
          cnt++;
        }
      }
      res += p[i][cnt];
    }
    ans = max(ans, res);
  }
  printf("%lld\n", ans);
  return 0;
}
