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

int f[200][10];
int p[200][20];

int main() {
  int n;
  cin >> n;
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];
  int mx = INT_MIN;
  rep(i, 1 << 10) {
    if (i == 0) continue;
    int ans = 0;
    rep(j, n) {
      int cnt = 0;
      rep(k, 10) {
        if ((i >> k & 1) && f[j][k] == 1) cnt++;
      }
      ans += p[j][cnt];
    }
    mx = max(mx, ans);
  }
  cout << mx << endl;
}
