#include <bits/stdc++.h>
using namespace std;
const int N = 1000060;
const int mod = (int)1e9 + 7;
const int MX = 1000020;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  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][11];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> p[i][j];
    }
  }
  int lim = 1 << 10;
  int res = -2e9;
  for (int i = 1; i < lim; ++i) {
    int tmp = 0;
    bool ok = false;
    for (int j = 0; j < n; ++j) {
      int cnt = 0;
      for (int bit = 0; bit < 10; ++bit) {
        if (f[j][bit] & ((1 << bit) & i)) cnt++;
      }
      if (cnt > 0) ok = true;
      tmp += p[j][cnt];
    }
    if (ok) res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}
