#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, f[110][11], p[110][11], ans = -(1 << 30), cnt, c;
int main(){
	cin >> n;
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	for (int i = 1;i < (1 << 10);i++) {
		cnt = 0;
		rep(j, n) {
			c = 0;
			rep(k, 10)if ((i >> k & 1) && f[j][k]) c++;
			cnt += p[j][c];
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}