#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
using namespace std;

int n, f[100][10], p[100][10], ans = 0;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) cin >> f[i][j];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) cin >> p[i][j];
    }
    for (int work = 1; work < (1 << 10); work++) {
        int t = 0;
        for (int i = 0; i < n; i++) {
            int count = 0;
            for (int j = 0; j < 10; j++) if ((work >> j & 1) && f[i][j]) count++;
            t += p[i][c];
        }
        if (ans < t) ans = t;
    }
    cout << ans << endl;
    return 0;
}