#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int F[n][10];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> F[i][j];
  int P[n][10];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> P[i][j];
  int ans = -1e9;
  for (int i = 1; i < (1 << 11); i++) {
    bitset<10> bs(i);
    int index = 0;
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        if (F[j][9 - k] & bs.test(k)) cnt++;
      }
      index += P[j][cnt];
    }
    ans = max(ans, index);
  }
  cout << ans << endl;
  return 0;
}
