#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

int pc(int a) {
	int res = 0;
	while (a > 0) {
		res += a % 2;
		a /= 2;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N, 0);
	vector<vector<int> >B(N, vector<int>(11));
	int res = 0;
	int a;
	for (int i = 0; i < N; i++) {
		A[i] = 0;
		for (int j = 0; j < 10; j++) {
			cin >> a;
			A[i] += a;
			A[i] *= 2;
		}
		A[i] /= 2;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> B[i][j];
		}
	}
	int res = -100000000;
	int sum = 0;
	for (int i = 1; i < ((int)1 << 10); i++) {
		sum = 0;
		for (int j = 0; j < N; j++) {
			sum += B[j][pc(i & A[j])];
		}
		res = max(res, sum);
	}
	cout << res << endl;
}