#include <bits/stdc++.h>
using namespace std;
static const int INF = (1<<30)-1;
int n,f[101][10],p[101][11];
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<11;j++) cin >> p[i][j];

  int benefit_max = -INF;
  for(int bit=1;bit<(1<<10);bit++){
    int benefit = 0;
    for(int i=0;i<n;i++){
      int cnt = 0;
      for(int j=0;j<10;j++){
        if(bit & (f[i][j] << j)) cnt++;
      }
      benefit += p[i][cnt];
    }
    if(benefit_max < benefit) benefit_max = benefit;
  }
  cout << benefit_max << endl;
  return 0;
}
