#include <bits/stdc++.h>
using namespace std;
int ans = -(1 << 30);
using ushort = unsigned short;
ushort my_shop = 0;
int n;
ushort others[110];
int profit[110][11];
void update(int n);
void calc_profit();
int pop_count(ushort a);
int pop_count(ushort a, ushort b);
int main() {
  cin >> n;
  int input;
  for (int j = 0; j < n; j++) {
    others[j] = 0;
    for (int i = 0; i < 10; i++) {
      cin >> input;
      others[j] |= (input << i);
    }
  }
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 11; i++) {
      cin >> input;
      profit[j][i] = input;
    }
  }
  update(0);
  cout << ans << endl;
  return 0;
}
void update(int n) {
  if (n == 10) {
    calc_profit();
    return;
  } else {
    my_shop |= (1 << n);
    update(n + 1);
    my_shop &= ~(1 << n);
    update(n + 1);
  }
}
inline int max(int a, int p) { return a < p ? p : a; }
void calc_profit() {
  int p = 0;
  for (int i = 0; i < n; i++) {
    p += profit[i][pop_count(my_shop, others[i])];
  }
  ans = max(ans, p);
}
int pop_count(ushort a) {
  a = (a & 0x5555) + ((a >> 1) & 0x5555);
  a = (a & 0x3333) + ((a >> 2) & 0x3333);
  a = (a & 0x0f0f) + ((a >> 4) & 0x0f0f);
  a = (a & 0x00ff) + ((a >> 8) & 0x00ff);
  return a;
}
int pop_count(ushort a, ushort b) { return pop_count(a & b); }
