import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9 + 7;

void main() {
    int n;
    scan(n);

    auto f = new int[][](n, 10);
    auto p = new int[][](n, 11);

    foreach (i ; 0 .. n) {
        f[i] = readln.split.to!(int[]);
    }

    foreach (i ; 0 .. n) {
        p[i] = readln.split.to!(int[]);
    }

    long ans = -inf;

    foreach (cmb ; 1 .. (1<<10)) {
        long t;

        foreach (mise ; 0 .. n) {
            int cnt;

            foreach (j ; 0 .. 10) {
                if (f[mise][j] && (cmb & (1<<j))) {
                    cnt++;
                }
            }

            t += p[mise][cnt];
        }

        ans = max(ans, t);
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}