#include <bits/stdc++.h>
long long CONS = 1e9 + 7;
using namespace std;
int main(void) {
  long long n;
  cin >> n;
  vector<vector<long long>> shop_time =
      vector<vector<long long>>(n, vector<long long>(10));
  vector<vector<long long>> shop_value =
      vector<vector<long long>>(n, vector<long long>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      long long f;
      cin >> f;
      shop_time[i][j] = f;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      long long v;
      cin >> v;
      shop_value[i][j] = v;
    }
  }
  long long ans = -1e10;
  for (int i = 1; i < pow(2, 10); i++) {
    vector<long long> shop_count = vector<long long>(n);
    for (int j = 0; j < 10; j++) {
      if (i & (1 << j)) {
        for (int k = 0; k < n; k++) {
          if (shop_time[k][j]) {
            shop_count[k]++;
          }
        }
      }
    }
    long long ans_cand = 0;
    for (int j = 0; j < n; j++) {
      ans_cand = shop_value[j][shop_count[j]];
    }
    ans = max(ans, ans_cand);
  }
  cout << ans << endl;
}
