using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int N;
    static bool[][] B;
    static int[][] P;

    static void INPUT()
    {
        N = NextInt();
        B = new bool[N][];
        P = new int[N][];
        for (int i = 0; i < N; i++)
            B[i] = LineInt().Select(__ => __ == 1).ToArray();
        for (int i = 0; i < N; i++)
            P[i] = LineInt();
    }
    static void OUT()
    {
        var max = int.MinValue;
        for (var b = 1; b < (1 << 10) - 1; b++)
        {
            var sum = 0;
            for(var n = 0; n < N; n++)
            {
                var nn = 0;
                for (var i = 0; i < 10; i++)
                {
                    if ((b >> i) % 2 == 1)
                    {
                        if (B[n][i]) nn++;
                    }
                }
                sum += P[n][nn];
            }

            max = Math.Max(max, sum);
        }

        Console.WriteLine(max);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        //S = "1222";
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}


