#include <map>
#include <iostream>
 
using namespace std;
 
int main() {
        int N;
	int a[N-1][9];
	long long int b[N-1][10];
	int c[9];
	long long int max = -10000000000;
    cin >> N ;
	for (int i = 0;i < N; i++){
	cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3] >> a[i][4] >> a[i][5] >> a[i][6] >> a[i][7] >> a[i][8] >> a[i][9] ;
}	for (int n = 0;n < N; n++){
	cin >> b[n][0] >> b[n][1] >> b[n][2] >> b[n][3] >> b[n][4] >> b[n][5] >> b[n][6] >> b[n][7] >> b[n][8] >> b[n][9] >> b[n][10] ;
}
	for(int j = 0;j < 1024; j++){
	for(int k = 0;k < 10;k++){
	c[k]=j%2;
	j = j-c[k]/2;
}
int a = 0;
int sum = 0;
for(int l = 0;l < N;l++){
for(int m = 0;l < 10;l++){
a = a + a[l][m]*c[m];
}
sum = sum + b[l][a];
}
max = max( max ,sum );
}
           cout << max << endl;
return 0;
} 
