#include <bits/stdc++.h>
using namespace std;
using namespace std;
template <typename T>
void putv(vector<T> &V) {
  for (auto x : V) cout << x << " ";
  cout << endl;
}
template <class T>
vector<T> getv(int n) {
  vector<T> vec;
  for (int i = (0); i < int(n); ++i) {
    T input;
    cin >> input;
    vec.emplace_back(input);
  }
  return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
  int src, dst;
  Weight weight;
  Flow cap;
  Edge() : src(0), dst(0), weight(0) {}
  Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
  g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
}
AdjList getadj(int N, int M) {
  vector<int> init;
  vector<vector<int>> graph(N, init);
  for (int i = (0); i < int(M); ++i) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].emplace_back(b - 1);
    graph[b - 1].emplace_back(a - 1);
  }
  return graph;
}
long long Manhattan_dist(long long x1, long long y1, long long x2,
                         long long y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
void out(bool ans) {
  if (ans == true)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}
void Out(bool ans) {
  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void OUT(bool ans) {
  if (ans == true)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F, P;
  vector<int> vec;
  for (int i = (0); i < int(N); ++i) {
    vec = getv<int>(10);
    F.emplace_back(vec);
  }
  for (int i = (0); i < int(N); ++i) {
    vec = getv<int>(11);
    P.emplace_back(vec);
  }
  int max = -1e7 * 10;
  int sum = 0;
  int cntr[10] = {};
  for (int i = 1; i < 1024; i++) {
    string joisino = bitset<10>(i).to_string();
    for (int i = (0); i < int(N); ++i) {
      for (int j = (0); j < int(10); ++j)
        if (F[i][j] == 1 && joisino[j] == '1') cntr[i]++;
      sum += P[i][cntr[i]];
    }
    if (sum > max) max = sum;
    for (int i = (0); i < int(N); ++i) cntr[i] = 0;
    sum = 0;
  }
  cout << max << endl;
}
