#include <bits/stdc++.h>
using namespace std;
class CShoppingStreet {
 public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int n;
    cin >> n;
    vector<vector<int>> f_vec(n, vector<int>(10, 0));
    vector<vector<int>> open(5, vector<int>(2, 0));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 10; ++j) {
        cin >> f_vec[i][j];
      }
    }
    vector<vector<int>> p(n, vector<int>(11));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 11; ++j) {
        cin >> p[i][j];
      }
    }
    int64_t ans = -1e9 + 7;
    for (int bit = 1; bit < (1 << 10); ++bit) {
      vector<int> tmp;
      int64_t tmp_ans = 0;
      for (int j = 0; j < 10; ++j) {
        if (bit & (1 << j)) {
          tmp.emplace_back(1);
        } else {
          tmp.emplace_back(0);
        }
      }
      vector<bool> check(10);
      for (int j = 0; j < n; ++j) {
        int count = 0;
        for (int k = 0; k < 10; ++k) {
          count += 1 & (tmp[k] == 1 && f_vec[j][k] == 1);
          check[k] = (check[k] || tmp[k] == 1 || f_vec[j][k] == 1);
        }
        tmp_ans += p[j][count];
      }
      if (!all_of(check.begin(), check.end(), [](bool x) { return x; }))
        tmp_ans = -1e9 + 7;
      ans = max(ans, tmp_ans);
    }
    cout << ans << endl;
  }
};
int main() {
  CShoppingStreet solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
