#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main (){
	int n; cin >> n;
	int benefit = 0;
	ll maxv = -1000000005;
	vector<vector<int> > v(n),p(n);
	rep(i,n)rep(j,10){
		int a; cin>>a;
		v[i].push_back(a);
	}
	rep(i,n)rep(j,10){
		int a; cin>>a;
		p[i].push_back(a);
	}
	for (int bit = 1; bit < (1 << 10);++bit){
		vector<int> count(n);
		ll sum = 0;
		rep(i,n){
			rep(j,10){
				if(bit&1<<j && v[i][j])count++;
			}
			sum += p[i][count];
		}
		maxv(maxv,sum);
	}
	cout << maxv << endl;
}
