using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var shopNum = int.Parse(Console.ReadLine());
        var openList = new int[shopNum, 10];
        var costList = new int[shopNum, 10];

        for (int s = 0; s < shopNum; s++)
        {
            var open = Console.ReadLine().Split(' ');
            for (int t = 0; t < 10; t++)
            {
                openList[s, t] = int.Parse(open[t]);
            }
        }

        for (int s = 0; s < shopNum; s++)
        {
            var cost = Console.ReadLine().Split(' ');
            for (int t = 0; t < 10; t++)
            {
                costList[s, t] = int.Parse(cost[t]);
            }
        }
        
        int maxCost = int.MinValue;
        for (int flag = 1; flag < 1024; flag++)
        {
            int cost = 0;
            for (int s = 0; s < shopNum; s++)
            {
                int openTime = 0;
                for (int t = 0; t < 10; t++)
                {
                    var isOwnOpen = (flag & (int)Math.Pow(2, t)) != 0; // 自分の店をその時間開けるか
                    if (isOwnOpen && (openList[s, t] != 0))
                    {
                        openTime++;
                    }
                }
                cost += costList[s, openTime];
            }
            maxCost = Math.Max(cost, maxCost);
        }
        Console.WriteLine(maxCost.ToString());
        
    }
}