use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<Vec<i64>> = vec![vec![]; n];
    let mut b: Vec<Vec<i64>> = vec![vec![]; n];

    for i in 0..n {
        for _ in 0..10 {
            let item = read();
            a[i].push(item);
        }
    }
    for i in 0..n {
        for _ in 0..10 {
            let item = read();
            b[i].push(item);
        }
    }
    let mut maxv: i64 = std::i64::MIN;

    for i in 1..1 << 10 {
        let mut ans = 0;
        for j in 0..n {
            let mut pc = 0;
            for k in 0..10 {
                if i & (1 << k) != 0 && a[j][k] == 1 {
                    pc += 1;
                }
            }
            ans += b[j][pc];
        }
        if maxv < ans {
            maxv = ans
        }
    }
    println!("{}", maxv);
}
