#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;

int n;
bool F[100][10];
int P[100][11];

int solve(int k) {
  int res = 0;
  rep(i, n) {
    int cnt = 0;
    rep(j, 10) {
      if (F[i][j] && (1 & (k >> j))) ++cnt;
    }
    res += P[i][cnt];
  }
  return res;
}

int main() {
  cin >> n;
  rep(i, n)rep(j, 10) cin >> F[i][j];
  rep(i, n)rep(j, 11) cin >> P[i][j];
  int ans = -1e9;
  for (int i = 1; i < (1 << 10); ++i) {
    ans = max(ans, solve(i));
  }
  cout << ans << endl;
  return 0;
}