package main

import "fmt"

type shop struct {
	openTimes []int
	profits   []int
}

func (s shop) calcProfit(open []int) int {
	sameCount := 0
	for i := 0; i < 10; i++ {
		if s.openTimes[i] == 1 && open[i] == 1 {
			sameCount++
		}
	}
	return s.profits[sameCount]
}

func main() {
	var N int
	fmt.Scan(&N)

	shopOpenTimes := make([][]int, N)
	for i := 0; i < N; i++ {
		ot := make([]int, 10, 10)
		for j := 0; j < 10; j++ {
			fmt.Scan(&ot[j])
		}
		shopOpenTimes[i] = ot
	}

	shopProfits := make([][]int, N)
	for i := 0; i < N; i++ {
		p := make([]int, 11, 11)
		for j := 0; j < 11; j++ {
			fmt.Scan(&p[j])
		}
		shopProfits[i] = p
	}

	shops := make([]shop, N)
	for i := 0; i < N; i++ {
		s := shop{openTimes: shopOpenTimes[i], profits: shopProfits[i]}
		shops[i] = s
	}

	max := -10000001
	for i := 1; i < (1 << uint(10)); i++ {
		open := make([]int, 10)
		for j := 0; j < 10; j++ {
			if i&(1<<uint(j)) > 0 {
				open[j] = 1
			} else {
				open[j] = 0
			}
		}

		sum := 0
		for _, s := range shops {
			sum += s.calcProfit(open)
		}

		if max < sum {
			max = sum
		}
	}

	fmt.Println(max)
}
