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

namespace Algorithm
{
    class Program
    {
        const int ShopCount = 10;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var openTimes = new int[N][];
            var prices = new int[N][];
            for (var i = 0; i < N; i++)
                openTimes[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (var i = 0; i < N; i++)
                prices[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var res = 0L;
            for (var bit = 1; bit < 1 << ShopCount; bit++)
            {
                var cc = 0;
                for (var i = 0; i < N; i++)
                {
                    var c = 0;
                    for (var j = 0; j < ShopCount; j++)
                    {
                        if ((bit & (1<<j)) != 0 && openTimes[i][j] == 1) c++;
                    }
                    cc += prices[i][c];
                    res = Math.Max(cc, res);
                }
            }
            Console.WriteLine(res);
        }
    }
}
