package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N int
	fmt.Scan(&N)
	sc.Split(bufio.ScanWords)
	f := make([][]int, N)
	p := make([][]int, N)
	for i := 0; i < N; i++ {
		f[i] = make([]int, 10)
		for j := 0; j < 10; j++ {
			sc.Scan()
			f[i][j], _ = strconv.Atoi(sc.Text())
		}
	}
	for i := 0; i < N; i++ {
		p[i] = make([]int, 11)
		for j := 0; j < 11; j++ {
			sc.Scan()
			p[i][j], _ = strconv.Atoi(sc.Text())
		}
	}

	r := -100000000
	for m := 1; m < (1 << uint(10)); m++ {
		sum := 0
		for i := 0; i < N; i++ {
			c := 0
			for j := 0; j < 10; j++ {
				//if (m & (1 << uint(j))) > 0 {
				if (m >> uint(j) & 1) > 0 {
					if f[i][j] > 0 {
						c++
					}
				}
			}
			sum += p[i][c]
		}
		r = Max(r, sum)
	}
	fmt.Println(r)
}
func Max(a, b int) int {
	if b > a {
		return b
	}
	return a
}
