#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  cin >> x;
  return x;
}
long long lin() {
  long long x;
  cin >> x;
  return x;
}
string sin() {
  string x;
  cin >> x;
  return x;
}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
int main() {
  int N;
  int F[N][10];
  long long P[N][11];
  cin >> N;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(11); j++) {
      cin >> P[i][j];
    }
  }
  int bit = 0;
  long long ans;
  int count;
  long long answer = 0;
  for (bit = 1; bit < (1 << 10); bit++) {
    ans = 0;
    for (int i = 0; i < (int)(N); i++) {
      count = 0;
      for (int j = 0; j < (int)(10); j++) {
        if ((bit >> j) & 1 == 1 && F[i][j] == 1) {
          count++;
        }
      }
      ans += P[i][count];
    }
    if (bit == 1) {
      answer = ans;
    } else {
      answer = max(answer, ans);
    }
  }
  cout << answer << endl;
}
