#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[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];
  long long ans = -100000000;
  for (int bit = 1; bit < (1 << 10); bit++) {
    long long tmp = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (bit & 1 << j && f[i][9 - j] == 1) cnt++;
      }
      tmp += p[i][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
