#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[n][10];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  int p[n][11];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) cin >> p[i][j];
  int mx = -1e9;
  for (int i = 0; i < 1 << 10; i++) {
    int sm = 0;
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) cnt += i >> k & f[j][k];
      sm += p[j][cnt];
    }
    mx = max(mx, sm);
  }
  cout << mx << endl;
  return 0;
}
