package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func intSlice(s string) []int {
	ss := strings.Split(s, " ")
	res := make([]int, len(ss))
	for i, v := range ss {
		iv, _ := strconv.Atoi(v)
		res[i] = iv
	}

	return res
}

func rep(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = i
	}
	return is
}

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

	// 店入力
	stores := make([]int, n)
	for i := 0; i < n; i++ {
		s := nextLine()
		is := intSlice(s)
		for j, v := range is {
			stores[i] |= (v << uint(9-j))
		}
	}

	// スコア入力
	scores := make([][]int, n)
	for i, _ := range rep(n) {
		scores[i] = make([]int, 11)
		l := nextLine()
		scores[i] = intSlice(l)

	}

	ans := -(1 << 32)
	for i := 0; i < (1 << 10); i++ {
		sum := 0
		for j, s := range stores {
			x := i & s

			// 同時開店している数を数える
			count := countBit(x)
			sum += scores[j][count]
		}
		if sum > ans {
			ans = sum
		}
	}

	fmt.Println(ans)

}

func countBit(x int) int {
	cnt := 0
	for i, _ := range rep(11) {
		y := x >> uint(i)
		if y&1 == 1 {
			cnt++
		}
	}

	return cnt

}
