#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
int n;
int f[100];
int p[100][10];
int pop(int v) {
  int x = 0;
  for (int i = 0; i < 10; ++i) {
    x += (v >> i) & 1;
  }
  return x;
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (10); ++j) {
      int x;
      cin >> x;
      f[i] += x << j;
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  int ans = -inf;
  for (int i = 0; i < (1 << 10); ++i) {
    if (i == 0) {
      continue;
    }
    int x = 0;
    for (int j = 0; j < (n); ++j) {
      x += p[j][pop(i & f[j])];
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
  return 0;
}
