#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long f[N][10];
  long long b[110] = {0};
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> f[i][j];
      b[i] |= (f[i][j] << j);
    }
  }
  long long cost[N][10 + 1];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> cost[i][j];
    }
  }
  long long ans = (-1) * 11 * (1e7);
  for (int bit = 1; bit < (1 << 10); ++bit) {
    long long tmp = 0;
    for (int i = 0; i < N; ++i) {
      bitset<10> bs;
      bs = bit & b[i];
      tmp += cost[i][bs.count()];
    }
    if (ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}
