#include <iostream>
#include <vector>
#include <climits>

using ll = long long;
#define int ll

using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<int> f(n, 0);
	vector<vector<int> > p(n, vector<int>(11));
	for(auto& fi : f){
		for(int i = 0; i < 10; i++){
			int t;
			cin >> t;
			fi <<= 1;
			fi += t;
		}
	}
	for(auto& pi : p){
		for(auto& pii : pi){
			cin >> pii;
		}
	}
	int m = INT_MIN;
	for(int i = 0; i < 1<<10; i++){
		int t = 0;
		for(int j = 0; j < n; j++){
			int c = 0;
			for(int fi = f[j] & i; fi; fi >>= 1){
				c += fi & 1;
			}
			t += p[j][c];
		}
		m = max(m, t);
	}
	cout << m << endl;
	return 0;
}
