#include <bits/stdc++.h>

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;

    vector<vector<int>> F(N, vector<int>(10));
    REP(i, N) {
        REP(j, 10) {
            std::cin >> F[i][j];
        }
    }
    vector<vector<int>> P(N, vector<int>(11));
    REP(i, N) {
        REP(j, 11) {
            std::cin >> P[i][j];
        }
    }

    ll max_profit = 0;
    for(size_t i = 1; i < (1 << 10); i++) {
        ll profit = 0;
        REP(k, N) {
            int cnt = 0;
            for(size_t j = 0; j < 10; j++) {
                if(i & (1 << j)) {
                    cnt += F[k][j] ? 1 : 0;
                }
            }
            profit += P[k][cnt];
        }
        chmax(max_profit, profit);
    }

    std::cout << max_profit << std::endl;

    return 0;
}
