#include <bits/stdc++.h>
using namespace std;
int store[11];
int nums[109][19];
int main() {
  int N;
  cin >> N;
  memset(store, 0, sizeof(store));
  memset(nums, 0, sizeof(nums));
  int n;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      store[i] *= 2;
      cin >> n;
      store[i] += n;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> nums[i][j];
    }
  }
  long long maxn = -10000000000000;
  for (int i = 1; i <= (2 << 9) - 1; i++) {
    long long m = 0;
    for (int j = 0; j < N; j++) {
      int v = store[j] & i;
      int c = 0;
      while (v > 0) {
        if ((v & 1) == 1) c++;
        v /= 2;
      }
      m += nums[j][c];
    }
    maxn = max(maxn, m);
  }
  cout << maxn << endl;
  ;
}
