#include <bits/stdc++.h>
using namespace std;
bool F[100][10];
long long P[100][11];
int c[100];
int ret_num(int bin, int f) {
  int num = 0;
  for (int i = 0; i < 10; i++) {
    bool b = (bin >> i) & 1;
    if (b & F[f][9 - i]) num++;
  }
  return num;
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++)
    for (int k = 0; k < 10; k++) cin >> F[i][k];
  for (int i = 0; i < N; i++)
    for (int k = 0; k < 11; k++) cin >> P[i][k];
  long long max = -100000000;
  long long sum;
  for (int b = 1; b < 1024; b++) {
    sum = 0;
    for (int i = 0; i < N; i++) c[i] = ret_num(b, i);
    for (int i = 0; i < N; i++) sum += P[i][c[i]];
    if (sum > max) max = sum;
  }
  cout << max << endl;
  return 0;
}
