#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  vector<vector<long long int>> P(N, vector<long long int>(11));
  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];
  long long int ans = -1e8;
  for (long long int i = 1; i < (1 << 10); i++) {
    vector<int> tmp(10);
    for (int j = 0; j < (int)(10); j++) tmp[j] = (i >> j) & 1;
    long long int score = 0;
    for (int j = 0; j < (int)(N); j++) {
      int hoge = 0;
      for (int k = 0; k < (int)(10); k++) hoge += F[j][k] * tmp[k];
      score += P[j][hoge];
    }
    ans = ((ans) > (score) ? (ans) : (score));
  }
  cout << ans << endl;
  return 0;
}
