#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	int f[n][10];
	REP(i,n)
		REP(j,10)
			cin >> f[i][j];
	int p[n][11];
	REP(i,n)
		REP(j,11)
			cin >> p[i][j];
	int ans = -INF;
	for(int bit = 1; bit < 1 << 10; bit++){
		int sum = 0;
		REP(i,n){
			int cnt = 0;
			REP(j,10){
				if((bit & 1 << j) && f[i][j] == 1) cnt++;
			}
			sum += p[i][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}