#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
typedef unsigned char UCHAR
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> G;
typedef pair<int, int> P;

int i,j,N;
bool F[100][10];
int P[100][11];
int pmax;

int main() {
	cin >> N;
	
	REPI(0,N) REPJ(0,10) cin >> F[i][j];
	REPI(0,N) REPJ(0,11) cin >> P[i][j];
	
	REPI(1,1024) {
		int x = 0;
		int cnt = 0;
		REPJ(0,N) {
			for (int k=0; k<10;k++) if (i&(1<<k)) cnt += F[i][k];
			x += P[i][cnt]
		}
		pmax = MAX(x, pmax);
	}
	
	cout << pmax;
	
	return 0;
}
