use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let n : usize = get_one();
    let mut fs = Vec::new();
    for _i in 0..n {
        let v : Vec<i32> = get_vec();
        fs.push(v);
    }
    let mut ps = Vec::new();
    for _i in 0..n {
        let v : Vec<i32> = get_vec();
        ps.push(v);
    }
    let mut ans = -1 * 100 * 10_i32.pow(7) - 500;
    for i in 1..1023 {
        let mut src = i;
        let mut bits = vec!(0;10);
        for j in 0..10 {
            bits[j] = src & 1;
            src = src >> 1;
        }
        let mut score = 0;
        for j in 0..n {
            let mut open = 0;
            for k in 0..10 {
                if bits[k] == 1 && fs[j][k] == 1 {
                    open += 1;
                }
            }
            score += ps[j][open];
        }
        ans = std::cmp::max(ans, score);
    }
    println!("{}", ans);
}
