#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return s; }
template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; i++) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}
void debug() { cerr << endl; }
template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}
void print() { cout << endl; }
template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}
int main() {
  int(N);
  scanf("%d", &(N));
  vector<vector<int>> F(N);
  for (int i = 0; i < (int)N; i++) {
    F[i] = vector<int>(10);
    for (int j = 0; j < (int)10; j++) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N);
  for (int i = 0; i < (int)N; i++) {
    P[i] = vector<int>(11);
    for (int j = 0; j < (int)11; j++) {
      cin >> P[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < (int)1024; i++) {
    vector<int> count(10);
    for (int j = 0; j < (int)10; j++) {
      if ((i >> j) & 1) {
        for (int k = 0; k < (int)N; k++) {
          if (F[k][j]) count[k]++;
        }
      }
    }
    int sum = 0;
    for (int j = 0; j < (int)N; j++) {
      sum += P[j][count[j]];
    }
    if (ans < sum) ans = sum;
  }
  print(ans);
  return 0;
}
