#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  std::bitset<10> f[109];
  int p[109][12];
  int n;
  std::cin >> n;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < 10; i++) {
      int temp;
      std::cin >> temp;
      f[k][i] = temp;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      std::cin >> p[i][j];
    }
  }
  int ans = -100000000;
  for (unsigned i = 1; i <= 1024; i++) {
    std::bitset<10> pa(i);
    int now = 0, tot = 0;
    for (int k = 0; k < n; k++) {
      now = 0;
      for (int j = 0; j < 10; j++) {
        if (f[k][j] & pa[j]) {
          now++;
        }
      }
      tot += p[k][now];
    }
    ans = std::max(tot, ans);
  }
  std::cout << ans << std::endl;
  return 0;
}
