#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long A;
  cin >> A;
  vector<vector<long long>> F(A, vector<long long>(10));
  for (long long i = 0; i < A; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> F.at(i).at(j);
    }
  }
  vector<vector<long long>> P(A, vector<long long>(10));
  for (long long i = 0; i < A; i++) {
    for (long long j = 0; j < 10; j++) {
      cin >> P.at(i).at(j);
    }
  }
  vector<vector<long long>> kumi(1200, vector<long long>(10));
  for (long long bit = 0; bit < (1 << 10); ++bit) {
    for (long long i = 0; i < 10; ++i) {
      if (bit & (1 << i)) {
        kumi.at(bit).at(i) = 1;
      }
    }
  }
  long long ans = -100000000000;
  for (long long i = 0; i < 1200; i++) {
    bool fg = true;
    long long rieki = 0;
    for (long long j = 0; j < 10; j++) {
      if (j % 2 == 1 && kumi.at(i).at(j) == 0 && kumi.at(i).at(j - 1) == 0) {
        fg = false;
      }
    }
    if (fg == false) continue;
    for (long long k = 0; k < A; k++) {
      long long cnt = 0;
      for (long long j = 0; j < 10; j++) {
        if (F.at(k).at(j) == 1 && kumi.at(i).at(j) == 1) cnt++;
      }
      rieki += P.at(k).at(cnt);
    }
    ans = max(ans, rieki);
  }
  cout << ans << endl;
}
