#include <bits/stdc++.h>

using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> f(n);
  for(auto&& x:f){
    for(int i=0;i<10;i++){
      int y;
      cin >> y;
      x <<= 1;
      x |= y;
    }
  }
  vector<vector<int> > p(n, vector<int>(11));
  for(auto&& x:p)for(auto&& y:x)cin >> y;
  int ans = -1e9-7;
  for(int i=1;i<(1<<10);i++){
   	int t = 0;
    for(int j=0;j<n;j++){
      int k = __builtin_popcount(i&f[j]);
      t += p[j][k];
    }
    ans = max(t, ans);
  }
  cout << ans << endl;
}