#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long f[n][10], p[n][11];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) cin >> p[i][j];
  long long ans = -1000000001;
  int a[10];
  for (int i = 1; i <= 1023; i++) {
    int pattern = i, j = 0;
    while (pattern != 0) {
      a[j] = pattern % 2;
      pattern /= 2;
      j++;
    }
    long long ans_tmp = 0;
    for (int k = 0; k < n; k++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (f[k][j] == 1 && a[j] == 1) cnt++;
      }
      ans_tmp += p[k][cnt];
    }
    ans = max(ans, ans_tmp);
  }
  cout << ans << endl;
}
