
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 900000001
using namespace std;
typedef long long ll;

int ans = -MAX;
int n;
int f[100][10];
int p[100][11];
int a[10];
void calc(){
  int score = 0;
  int notAll0 = false;
  rep(i, 0, 10) if(a[i]&1) notAll0 = true;
  if(!notAll0)  return;
  rep(i, 0, n) {
    int c = 0;
    rep(j, 0, 10) {
      if(a[j]&f[i][j]) c++;
    }
    score += p[i][c];
  }
  ans = max(ans, score);
}

void dfs(int pos){
  if(pos==10){
    calc();
    return;
  }
  a[pos]=0; dfs(pos+1);
  a[pos]=1; dfs(pos+1);
}

int main(){
  cin >> n;
  rep(i, 0, n)  rep(j, 0, 10) cin >> f[i][j];
  rep(i, 0, n)  rep(j, 0, 11) cin >> p[i][j];
  dfs(0);
  cout << ans << endl;
  return 0;
}