#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<int>> F;
vector<vector<int>> P;
int ans = -1000000001;
void check(vector<int> A) {
  int an = 0;
  for (int i = 0; i < (N); i++) {
    int nn = 0;
    for (int j = 0; j < (10); j++)
      if (A[j] * F[i][j] != 0) nn++;
    an += P[i][nn];
  }
  ans = max(ans, an);
}
void dfs(vector<int> A, int i) {
  int n = i;
  if (i == 10) {
    check(A);
  } else {
    if (n != 0) dfs(A, n + 1);
    A[n] = 1;
    dfs(A, n + 1);
  }
}
int main() {
  cin >> N;
  F.assign(N, vector<int>(10, 1));
  P.assign(N, vector<int>(11, 1));
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (10); j++) cin >> F[i][j];
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (11); j++) cin >> P[i][j];
  vector<int> A(10, 0);
  dfs(A, 0);
  cout << ans << endl;
  return 0;
}
