#include <iostream>
#include <cstdio>
#define N 105
#define M 15
using namespace std;

int n, m = 10, c, s, mx = -2e9, a[N][M], b[N][M];
int main()
{
	int i, j, k, t;
	cin >> n;
	for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	for (i = 0; i < n; i++) for (j = 0; j <= m; j++) scanf("%d", &b[i][j]);
	for (i = 1; i < (1 << m); i++) {
		s = 0;
		for (j = 0; j < n; j++) {
			c = 0;
			for (t = i, k = m - 1; k >= 0; t /= 2, k--) c += a[j][k] & (t % 2);
			s += b[j][c];
		}
		mx = max(mx, s);
	}
    cout << mx << endl;
    return 0;
}