#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(ll i=(n);i<(x);++i)
using ll = long long;

int main() {
	int n; cin >> n;
	vector<vector<int>> f(n, vector<int>(10, 0));
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> f[i][j];
		}
	}
	vector<vector<ll>> p(n, vector<ll>(11, 0));
	rep(i, 0, n) {
		rep(j, 0, 11) {
			cin >> p[i][j];
		}
	}

	ll ans = -1e7 * 100;
	int num = pow(2, 10);
	rep(i, 1, num) {
		ll P = 0;
		bitset<10> open(i);
		rep(j, 0, n) {
			int c = 0;
			rep(k, 0, 10) {
				if (open[k] && f[j][k]) c++;
			}
			P += p[j][c];
		}
		ans = max(ans, P);
	}

	cout << ans << endl;

	return 0;
}