#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> f, p;
void solve() {
  int i, j;
  long long bit, cnt, tmp, ans;
  ans = -1000000000 - 1;
  for (bit = 0; bit < (1 << 10); bit++) {
    tmp = 0;
    for (i = 0; i < n; i++) {
      cnt = 0;
      for (j = 0; j < 10; j++) {
        if ((bit & (1 << j)) && f[i][j] == 1) {
          cnt++;
        }
      }
      tmp += p[i][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << "\n";
}
int main() {
  int i, j, tmp;
  cin >> n;
  f.resize(n);
  p.resize(n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < 10; j++) {
      cin >> tmp;
      f[i].push_back(tmp);
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j <= 10; j++) {
      cin >> tmp;
      p[i].push_back(tmp);
    }
  }
  solve();
  return 0;
}
