#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, ans = INT_MIN;
    cin >> n;
    vector<vector<int>> shop(n, vector<int>(10)), price(n, vector<int>(11));
    rep(i, n) rep(j, 10) cin >> shop.at(i).at(j);
    rep(i, n) rep(j, 11) cin >> price.at(i).at(j);
    rep(i, (1 << 10) - 1) {
        int temp = 0;
        rep(j, n) {
            int cnt = 0;
            rep(k, 10) if((1 & ((i + 1) >> k)) && shop.at(j).at(k)) cnt++;
            temp += price.at(j).at(cnt);
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}