#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int f[100][14];
int p[100][15];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n)
    {
        rep(j, 10)
        {
            cin >> f[i][j];
        }
    }
    rep(i, n)
    {
        rep(j, 11)
        {
            cin >> p[i][j];
        }
    }
    int ans = -(1 << 30);
    for (int b = 1; b < (1 << 10); b++)
    {
        int sum = 0;
        rep(i, n)
        {
            int count = 0;
            rep(j, 10)
            {
                if ((b >> j & 1) && f[i][j])
                    count++;
            }
            sum += p[i][c];
        }
        ans = max(ans, sum);
    }
    cout << ans << "\n";
}