#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<vector<long long int>> f;
  vector<vector<long long int>> p;
  long long int max = -999999999;
  cin >> n;
  f.resize(n);
  p.resize(n);
  for (auto& m : f) {
    m.resize(10);
    for (auto& j : m) cin >> j;
  }
  for (auto& m : p) {
    m.resize(11);
    for (auto& j : m) cin >> j;
  }
  int num = 0;
  while (1) {
    bitset<10> bit(num);
    if (bit.any()) {
      vector<long long int> fsum;
      fsum.resize(n);
      for (int i = 0; i < 10; ++i) {
        for (int m = 0; m < n; ++m)
          if (bit[i] && f.at(m).at(i) == 1) ++fsum.at(m);
      }
      int s = 0;
      for (int m = 0; m < n; ++m) {
        s += p.at(m).at(fsum.at(m));
      }
      if (max < s) max = s;
    }
    if (bit.all()) break;
    ++num;
  }
  cout << max << endl;
  return 0;
}
