#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
void bulk() {}
template <class H, class... T>
void bulk(H &h, T &...t) {
  cin >> h;
  bulk(t...);
}
int main(void) {
  int n;
  cin >> n;
  vector<int> shop(n, 0);
  vvi c(n, vi(11));
  for (auto &i : shop) {
    for (int j = 0; j < 10; j++) {
      int t;
      cin >> t;
      i = i * 2 + t;
    }
  }
  for (auto &l : c)
    for (auto &i : l) cin >> i;
  int ans = -1000000000;
  for (int i = 0; i < 1024; i++) {
    int cost = 0;
    for (int j = 0; j < n; j++) {
      cost += c[j][__builtin_popcount(i & shop[j])];
    }
    ans = max(ans, cost);
  }
  cout << ans;
}
