#include <iostream>
#include <vector>

using namespace std;

int f[100][10] = {};
long long p[100][11] = {};
int n;
long long total = -1000000000000;

vector<int> v;
vector<int> ans;

long long calc_score(){
  long long tmp_toatal = 0;
  for (int i=0;i<n;i++) {
    int simul_open = 0;
    for (int j=0;j<10;j++) {
      if (v[j] == 1 && f[i][j] == 1) {
	simul_open++;
      }
    }
    tmp_total += p[i][simul_open];
  }
  return(tmp_total);
}

void dfs(int k){
  if (k==10) {
    int open_sum = 0;
    for (int i=0;i<10;i++) {
      open_sum += v[i];
    }
    if (open_sum > 0) {
      long long tmp_total = calc_score();
      if (tmp_total > total) {
	total = tmp_total;
      }
    }
    return;
  }
  v.push_back(1);
  dfs(k+1);
  v.pop_back();
  v.push_back(0);
  dfs(k+1);
  v.pop_back();
  return;
}

int main(){
  cin >> n;
  for (int i=0;i<n;i++) {
    for (int j=0;j<10;j++) {
      int tmp;
      cin >> tmp;
      f[i][j] = tmp;
    }
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<=10;j++) {
      long long tmp;
      cin >> tmp;
      p[i][j] = tmp;
    }
  }
  dfs(0);
  cout << total << endl;
  return(0);
}

