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

namespace SandboxCSharp
{
    class Solver
    {

        public void Solve()
        {
            int n = io.ScanInt();

            var ff = new int[n];
            var pp = new int[n, 11];

            for (int i = 0; i < n; ++i)
                for (int j = 0; j < 10; ++j)
                    ff[i] |= io.ScanInt() << j;
            for (int i = 0; i < n; ++i)
                for (int j = 0; j <= 10; ++j)
                    pp[i, j] = io.ScanInt();

            int best = (int)-2e9;
            for (int b = 1; b < (1 << 10); ++b)
            {
                var con = new int[n];
                for (int i = 0; i < n; ++i)
                {
                    int c = (ff[i]&b);
                    while (c > 0) { con[i] += c & 1; c >>= 1; }
                }
                int curr = 0;
                for (int i = 0; i < n; ++i)
                {
                    curr += pp[i, con[i]];
                }
                best = Math.Max(best, curr);
            }

            io.WriteLine(best);
        }

        // =================================================
        // =================================================

        Stdio io;
        bool isjdg;
        static void Main()
        {
            var s = new Solver();
            s.Solve();
            s.io.Flush();
        }
        public Solver(Stdio _io = null)
        {
            isjdg = _io == null;
            io = _io == null ? new Stdio() : _io;
        }

        void Exit()
        {
            if (isjdg)
            {
                io.Flush();
                Environment.Exit(0);
            }
            else
                throw new HaltException();
        }
    }
    class Stdio
    {
        protected string[] stack = new string[0];
        protected int stackptr = 0;
        protected StringBuilder outbuff = new StringBuilder();

        public virtual int ScanInt()
        {
            return Check() ? int.Parse(stack[stackptr++]) : 0;
        }
        public virtual long ScanLong()
        {
            return Check() ? long.Parse(stack[stackptr++]) : 0;
        }
        public virtual string ScanString()
        {
            return Check() ? stack[stackptr++] : string.Empty;
        }
        public virtual double ScanDouble()
        {
            return Check() ? double.Parse(stack[stackptr++]) : 0;
        }
        protected virtual bool Check()
        {
            if (stackptr < stack.Length) return true;
            var l = Console.ReadLine();
            if (l == null) return false;
            stack = l.Split(' ').ToArray(); stackptr = 0;
            return Check();
        }
        public Stdio Write(long v) { return Write($"{v}"); }
        public Stdio WriteLine(long v) { return WriteLine($"{v}"); }
        public Stdio Write(string str)
        {
            outbuff.Append(str);
            return this;
        }
        public Stdio WriteLine(string str = "")
        {
            outbuff.AppendLine(str);
            return this;
        }
        public virtual Stdio Flush()
        {
            Console.Write(outbuff.ToString());
            outbuff.Clear();
            return this;
        }
    }
    class HaltException : Exception { }

}


Measured memory_bytes: 13268