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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

bool open[105][11];
int profit[105][11];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int d = 1; d <= 10; d++) {
			int x;
			cin >> x;
			open[i][d] = (x == 1);
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int d = 1; d <= 10; d++) {
			cin >> profit[i][d];
		}
	}
	ll ans = 0;
	for(int open = 1; open < 2048; open++) {
		ll sum = 0;
		for(int i = 1; i <= 10; i++) {
			if(open&(1<<(i-1))) {
				for(int j = 1; j <= n; j++) {
					if(open[j][i]) {
						sum+= profit[j][i];
					}
				}
			}
		}
		ans = max(ans,sum);
	}
	cout << ans;
	return 0;
}

