#include <bits/stdc++.h>
using namespace std;
long long int a = 0, n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0;
string s;
char c;
bool flag;
int main(void) {
  long long int F[105][20];
  long long int P[105][20];
  cin >> n;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    for (long long int j = (long long int)(0); j < (long long int)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    for (long long int j = (long long int)(0); j < (long long int)(11); j++) {
      cin >> P[i][j];
    }
  }
  m = -100000000;
  for (long long int bit = (long long int)(1); bit < (long long int)(1024);
       bit++) {
    sum = 0;
    for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
      cnt = 0;
      for (long long int j = (long long int)(0); j < (long long int)(10); j++) {
        if (((bit >> j) & 1) && F[i][j] == 1) {
          cnt++;
        }
      }
      sum += P[i][cnt];
    }
    if (m < sum) {
      m = sum;
    }
  }
  cout << m << endl;
  return 0;
}
