#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

vector<int> a(10);
int N;
vector<vector<ll>> F;
vector<vector<ll>> P;
ll ans = -INF64;

auto cal = []() {
    // すべて0のときは題意に合わない
    if (count(ALL(a), 1) > 0)
        return;

    ll score = 0;
    REP(i, N) {
        int cnt = 0;
        REP(j, 10) if (a[j] == 1 && F[i][j] == 1) { cnt++; }
        score += (ll)P[i][cnt];
    }

    chmax(ans, score);
};

auto dfs = [](auto pos) {
    if (pos == 10) {
        cal();
        return;
    }
    a[pos] = 0;
    dfs(pos + 1);
    a[pos] = 1;
    dfs(pos + 1);
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    F.resize(N, vector<ll>(10));
    P.resize(N, vector<ll>(11));
    REP(i, N) REP(j, 10) cin >> F[i][j];
    REP(i, N) REP(j, 11) cin >> P[i][j];

    dfs(0);

    cout << ans << endl;

    return 0;
}