#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int f[100][10];
int p[100][11];

signed main() {
	int i, j, k;
	
	cin >> n;
	rep(i, n) rep(j, 10) cin >> f[i][j];
	rep(i, n) rep(j, 11) cin >> p[i][j];
	
	int ans = -1e+15;
	rep(i, (1 << 10)) {
		if (i == 0) continue;
		int sumP = 0;
		rep(j, n) {
			int cnt = 0;
			rep(k, 10) {
				if ((i >> k) % 2 == 1 && f[j][k] == 1) {
					cnt++;
				}
			}
			sumP += p[j][cnt];
		}
		ans = max(ans, sumP);
	}
	cout << ans << endl;
	return 0;
}