#include <bits/stdc++.h>
int f[105][12];
int p[105][12];
int N;
int main() {
  std::cin >> N;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 10; ++j) std::cin >> f[i][j];
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 11; ++j) std::cin >> p[i][j];
  long long ans = -(1LL << 15);
  for (int s = 1, end = 1 << 10; s < end; ++s) {
    int res = 0;
    for (int i = 0; i < N; ++i) {
      int cnt = 0;
      for (int j = 0; j < 10; ++j)
        if (((s >> j) & 1) && f[i][j]) ++cnt;
      res += p[i][cnt];
    }
    ans = std::max<long long>(ans, res);
  }
  std::cout << ans << std::endl;
  return 0;
}
