#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
#define point complex<double>
#define pi acos(-1)
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

long long adotb(point a, point b){
    return (conj(a)*b).real();
}

long long acrossb(point a, point b){
    return (conj(a)*b).imag();
}

long long sinseta(point a, point b){
    return abs(acrossb(a,b)/(abs(a)*abs(b)));
}
ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod ;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

ll lcm(ll a, ll b){
    return (a*b)/__gcd(a,b);
}
long double  NCR(int n, int m){
    if(n<m)return 0;
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll stolong(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
const int MAXN=1e7+2;
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

vector<int> getFactorization(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.pb(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

ll dis(int x1, int x2, int y1, int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

class data{
    public:
    ll x, y, f, s, i, d;
    data(){}
    data(int xx, int yy, int ff, int ss, int ii){
        x=xx; y=yy; f=ff; s=ss; i=ii;
        d=dis(f, x, s, y);
    }
    operator <(data& o) {
        return d<o.d;
    }

};

double distance(point a, point b){
    return abs(b-a);
}

string ltobin(int x){
    string res="";
    while(x){
        res+=('0'+(x%2)); x/=2;
    }
    reverse(res.begin(), res.end());
    return res;
}
ll bintol(string a){
    ll res=0;
    reverse(a.begin(), a.end());
    for(int i=0; i<a.size(); i++){
        if(a[i]=='1')res+=pow(2,i);
    }
    return res;
}
void primeFactors(int n)
{
    while (n % 2 == 0 && n)
    {
        cout<<2<<" ";
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout<<i<<" ";
            n = n/i;
        }
    }
    if (n > 2)
        cout<<n<<" ";
}

int main()
{
    Fastio();
    int ttt=1; //cin>>ttt;
    while(ttt--){
        ll n, arr[105][11], p[105][12];
        cin>>n;
        for(int i=0; i<n; i++){
            for(int y=0; y<10; y++){
                cin>>arr[i][y];
            }
        }
        for(int i=0; i<n; i++)
            for(int y=0; y<=10; y++){cin>>p[i][y];}
        ll res=-1e18;
        for(int i=1; i<=(1<<10)-1; i++){
            ll ans=0;
            for(int y=0; y<n; y++){
                int c=0;
                for(int j=0; j<10; j++){
                    if(!arr[y][j] || (i>>j)%2==0)continue;
                    c++;
                }
                ans+=p[y][c];
            }
            res=max(res, ans);
        }
        cout<<res<<'\n';
    }

    return 0;
}
