using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var shop = new int[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var wk = Array.ConvertAll(line, int.Parse);
            shop[i] = Convert.ToInt32(string.Join("", wk), 2);
        }
        var p = new int[n, 11];
        for (int i = 0; i < n; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 11; j++) p[i, j] = int.Parse(line2[j]);
        }
        var pmax = -999999999;
        for (int i = 1; i <= 1023; i++)
        {
            var psum = p[0, countBit(i & shop[0])];
            for (int j = 1; j < n; j++)
                psum += p[j, countBit(i & shop[j])];
            pmax = Math.Max(pmax, psum);
        }
        Console.WriteLine(pmax);
    }
    public static int countBit(int bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
    }
}