#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main()
{
	int n;
	cin >> n;

	vector<vector<int>> f(n, vector<int>(10));

	rep(i, n){
		rep(j, 10){
			cin >> f.at(i).at(j);
		}
	}

	vector<vector<int>> p(n, vector<int>(11));

	rep(i, n){
		rep(j, 11){
			cin >> p.at(i).at(j);
		}
	}

	int max = INT_MIN;

	// cout << p[0][1] << endl;
	for(int bit = 0; bit < (1<<10); ++bit){	
		int dab[n] = {0};
		bool changed = false;
		rep(i, n){
			rep(j, 10){
				if(bit&(1<<j) && f[i][j]==1){
					dab[i]++;
					changed = true;
				}
			}
		}
		int sum=0;
		rep(i, n){
			sum += p[i][dab[i]];
		}

		if(sum > max && changed == true) {
			// cout << "changed " <<dab[0] << "sum " << sum << endl;
			// cout << "1:" << dab[0] << " 2:" << dab[1] << endl;
			// cout << p[0][1] << endl;
			max = sum;
		}else{
		
		}
	}

	cout << max << endl;
}

