use proconio::input;

fn main() {
    input! {
        n: usize,
        f: [[usize; 10]; n],
        p: [[isize; 11]; n]
    }

    let mut max = isize::MIN;
    for bit in 1..1<<10 {
        let mut counter = vec![0; n];
        for i in 0..10 {
            if (bit >> i) & 1 != 0 {
                for j in 0..n {
                    if f[j][i] == 1 {
                        counter[j] += 1;
                    }
                }
            } 
        }


        let mut sum = 0;
        for i in 0..n {
            sum += p[i][counter[i]];
        }

        if sum > max {
            max = sum;
        }
    }

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