#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	ll n, f[110][11], p[110][11], ans = -1e15;
	cin >> n;
	for (int i = 0; i < n; i++) for (int j = 0; j < 10; j++)cin >> f[i][j];
	for (int i = 0; i < n; i++)for (int j = 0; j <= 10; j++)cin >> p[i][j];
	for (int i = 1; i < 1024; i++) {
		ll num = 0;
		for (int j = 0; j < n; j++) {
			ll cnt = 0;
			for (int k = 0; k < 10; k++) {
				if ((i&(1 << k))&&f[j][k])cnt++;
			}
			num += p[j][cnt];
		}
		ans = max(num, ans);
	}
	cout << ans << endl;
	return 0;
}
