use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut f: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut fi: Vec<char> = Vec::new();
        for _ in 0..10 {
            fi.push(iterator.next().unwrap().parse().unwrap());
        }
        f.push(fi);
    }
    let mut p: Vec<Vec<isize>> = Vec::new();
    for _ in 0..n {
        let mut pi: Vec<isize> = Vec::new();
        for _ in 0..11 {
            pi.push(iterator.next().unwrap().parse().unwrap());
        }
        p.push(pi);
    }

    let mut ans: isize = std::isize::MIN;
    for i in 1..(1<<10) {
        let q: Vec<char> = binary_string(i, 10).chars().collect();
        let mut current = 0;
        for j in 0..n {
            let mut count = 0;
            for k in 0..10 {
                if q[k] == '1' && f[j][k] == '1' {
                    count += 1;
                }
            }
            current += p[j][count]
        }
        ans = max(ans, current);
    }
    ans.to_string()
}
