//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int n;
int f[100][10], p[100][11];

void solve()
{
	long long maxi = -1*INF;
	FOR(num, 1, 1024)
	{
		int a[10];
		int x = num;
		REP(i,10)
		{
			a[i] = num%2;
			num /= 2;
		}
		num = x;

		int sum = 0;
		REP(i,n) 
		{
			int count = 0;
			REP(j,10) if(f[i][j]*a[j]==1) count++;
			sum += p[i][count];
		}

		maxi = max(maxi, sum);
	}
	cout << maxi << endl;
}

int main()
{
	cin >> n;
	REP(i,n) REP(j,10) cin >> f[i][j];
	REP(i,n) REP(j,11) cin >> p[i][j];

	solve();
}