#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Main() {
  u_int N;
  cin >> N;
  vector<int> F(N);
  int a;
  bitset<10> f;
  f.set();
  for (int i = (0); i <= (N - 1); ++i) {
    for (int j = (0); j <= (9); ++j) {
      cin >> a;
      if (a == 0) f.flip(j);
    }
    F[i] = f.to_ulong();
  }
  int P[N][11];
  for (int i = (0); i <= (N - 1); ++i) {
    for (int j = (0); j <= (10); ++j) {
      cin >> P[i][j];
    }
  }
  int ans = -1000;
  int money = 0;
  bitset<10> same;
  for (int date = (0); date <= ((1LL << 10) - 1); ++date) {
    money = 0;
    for (int i = (0); i <= (N - 1); ++i) {
      same = (bitset<10>)(F[i] & date);
      money += P[i][same.count()];
    }
    ans = max(money, ans);
  }
  cout << ans << endl;
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
