#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!(n:usize);
    
    let mut f : Vec<usize> = vec![];
    for i in 0..n{
        input!{c : [usize;10]}
        let mut tmp = 0;
        for i in 0..10{
            tmp += c[9-i] * 2u32.pow(i as u32) as usize
        }
        f.push(tmp);
    }

    let mut p = vec![];
    for i in 0..n{
        input!{pp : [i64;11]}
        p.push(pp);
    }

    let mut ans : i64= -1_000_000_000;
    for i in 1..(1 << 10){
        let mut tmp = 0;
        for j in 0..n{
            let x : usize = i & f[j];
            let y = (x as u32).count_ones();
            tmp += p[j][y as usize];
        }
        
        ans = max(ans,tmp);
    }

    println!("{}",ans);

}#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!(n:usize);
    
    let mut f : Vec<usize> = vec![];
    for i in 0..n{
        input!{c : [usize;10]}
        let mut tmp = 0;
        for i in 0..10{
            tmp += c[9-i] * 2u32.pow(i as u32) as usize
        }
        f.push(tmp);
    }

    let mut p = vec![];
    for i in 0..n{
        input!{pp : [i64;11]}
        p.push(pp);
    }

    let mut ans : i64= -1_000_000_000;
    for i in 1..(1 << 10){
        let mut tmp = 0;
        for j in 0..n{
            let x : usize = i & f[j];
            let y = (x as u32).count_ones();
            tmp += p[j][y as usize];
        }
        
        ans = max(ans,tmp);
    }

    println!("{}",ans);

}