#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, ans = INT_MIN;
	cin >> N;
	vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
	for (vector<int>& i : F) {
		for (int& j : i) cin >> j;
	}
	for (vector<int>& i : P) {
		for (int& j : i) cin >> j;
	}
	for (int i = 1; i < 1024; i++) {
		bitset<10> a = i;
		int b = 0;
		for (int j = 0; j < N; j++) {
			int c = 0;
			for (int k = 0; k < 10; k++) {
				if (F[j][k] == 1 && a[k]) c++;
			}
			b += P[j][c];
		}
		ans = max(ans, b);
	}
	cout << ans;
}