#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

long long s = -999999999999;
int a[25];
int N;
bool F[100][11];
long long P[100][11];

void func(void) {
	long long  sco = 0;
	bool abc = false;
	for(int i=0;i<N;i++){
		int abcd = 0;
		for(int j =0;j<10;j++) {
          
			if (a[j] == 1)abc = true;
          
			if (F[i][j] == 1)if (a[j] == 1)abcd++;
		}
		sco += P[i][abcd];
	}
  
	if(abc)ans = max(ans, sco);
}
void dfs(int pos) {
	if (pos == 10) {
		func();
		return;
	}
	a[pos] = 0; dfs(pos + 1);
	a[pos] = 1; dfs(pos + 1);
}
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
      for int i=0;i<=10;i++)cin >> F[i][j];
    }
	for(int i=0;i<N;i++){
      for(int i=0;i<11;i++)cin >> P[i][j];
    }
  
	dfs(0);
	cout << ans << endl;
}