#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  vector<vector<int>> P(N, vector<int>(11));
  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];
    }
  }
  int res = -1000000000;
  for (int i = 0; i < (1 << 10); i++) {
    int profit = 0;
    for (int j = 0; j < N; j++) {
      int count = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k) & 1 && F[j][k]) count++;
      }
      profit += P[j][count];
    }
    res = max(res, profit);
  }
  cout << res << endl;
  return 0;
}
