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

int main() {
  int n;
  int f[100][14];
  int p[100][15];
  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; 
  rep(bit, (1<<10)) {
    if (bit == 0) continue;
    int sum = 0;
    rep(i, n) {
      int c = 0;
      rep(j, 10) if (bit & (1<<j)) if (f[i][j]) c++;
      sum += p[i][c];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
