#include <bits/stdc++.h>
using namespace std;
const int NINF = -1000000000;
int main(){
  int N;
  cin >> N;
  vector<int> F(N, 0);
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 10; j++){
      int f;
      cin >> f;
      F[i] |= (f << j);
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= 10; j++){
      cin >> P[i][j];
    }
  }
  int x = NINF;
  for (int i = 1; i < (1 << 10); i++){
    int g = 0;
    for (int j = 0; j < N; j++){
      g += P[j][__builtin_popcount(i & F[j])];
    }
    x = max(x, g);
  }
  cout << x << endl;
}