#include <bits/stdc++.h>
using namespace std;
int ans = -1e7 - 3;
int N;
int a[10];
int F[100][10];
int P[100][11];
void dfs(int i) {
  if (i == 10) {
    int score = 0;
    int sums = 0;
    for (int j = 0; j < N; ++j) {
      int sum = 0;
      for (int k = 0; k < 10; ++k) {
        if (F[j][k] == 1 && a[k] == 1) {
          sum++;
          sums++;
        }
      }
      score += P[j][sum];
    }
    if (sums > 0) {
      ans = max(ans, score);
    }
    return;
  }
  a[i] = 0;
  dfs(i + 1);
  a[i] = 1;
  dfs(i + 1);
}
int main() {
  cin >> N;
  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 <= 10; ++j) {
      cin >> P[i][j];
    }
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
