package main

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

func solve() {
	n := getInt()
	fss := make([][]int, n)
	for i := range fss {
		fss[i] = getIntSlice(10)
	}

	ps := make([][]int, n)
	for i := range ps {
		ps[i] = getIntSlice(11)
	}

	ans := -1 * inf
	for bit := 1; bit < (1 << uint(10)); bit++ {
		now := 0
		for i, fs := range fss {
			c := bitCount(bit, fs)
			now += ps[i][c]
		}
		ans = max(ans, now)
	}

	fmt.Fprintln(wr, ans)
}

func bitCount(bit int, fs []int) int {
	ret := 0
	for i, f := range fs {
		if (bit & (f << i)) > 0 {
			ret++
		}
	}
	return ret
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}
