package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	N, _ := strconv.Atoi(s.Text())

	var F [100][10]int
	var P [100][11]int
	for i := 0; i < N; i++ {
		s.Scan()
		fTexts := strings.Split(s.Text(), " ")
		for j, fText := range fTexts {
			F[i][j], _ = strconv.Atoi(fText)
		}
	}

	for i := 0; i < N; i++ {
		s.Scan()
		pTexts := strings.Split(s.Text(), " ")
		for j, pText := range pTexts {
			P[i][j], _ = strconv.Atoi(pText)
		}
	}

	var profit float64 = - (1 << 30)

	for i := 1; i < 2^10; i++ {
		tmpProfit := 0.0
		for j := 0; j < N; j++ {
			openCount := 0
			uj := uint(j)
			for k := 0; k < 10; k++ {
				if ((i >> (uj & 1)) != 0 && F[j][k] == 1) {
					openCount++
				}
			}

			tmpProfit += float64(P[j][openCount])
		}
		profit = math.Max(profit, tmpProfit)
	}

	fmt.Println(profit)
}
