#include <bits/stdc++.h>
using std::cin;
using std::copy;
using std::copy_if;
using std::cout;
using std::endl;
using std::find_if;
using std::lower_bound;
using std::pair;
using std::sort;
using std::string;
using std::upper_bound;
using std::vector;
int n;
vector<int> f;
vector<vector<long>> p;
long eval(int x) {
  long e = 0;
  for (int i = 0; i < n; i++) {
    int _e = f[i] & x;
    int count = 0;
    while (_e > 0) {
      if (_e % 2 == 1) {
        count++;
      }
      _e /= 2;
    }
    e += p[i][count];
  }
  return e;
}
long search() {
  long max = eval(1);
  for (int i = 2; i < (1 << 10) - 1; i++) {
    max = std::max(max, eval(i));
  }
  return max;
}
int main() {
  cin >> n;
  f = vector<int>(n);
  for (int i = 0; i < n; i++) {
    int _f = 0;
    for (int j = 0; j < 10; j++) {
      int x;
      cin >> x;
      _f = _f * 2 + x;
    }
    f[i] = _f;
  }
  p = vector<vector<long>>(n, vector<long>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int result = search();
  cout << result << endl;
  return 0;
}
