#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, F[100][10], P[100][11], ans = -1000000000, c, cc;
	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++) {
		cc = 0;
		for (int j = 0; j < N; j++) {
			int X = i;
			c = 0;
			for (int k = 0; k < 10; k++) {
				if (X % 2 == 1 && F[j][k] == 1) {
					c++;
				}
				X /= 2;
			}
			cc += P[j][c];
		}
		ans = max(ans, cc);
	}
	cout << ans;
}