#include <bits/stdc++.h>
using namespace std;
int n;
bool open[105][15];
int p[105][15];
int cal(int x) {
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = 0; j <= 9; j++)
      if (open[i][j] && (x & (1 << j))) sum++;
    ret += p[i][sum];
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 9; j++) cin >> open[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  int res = -(1 << 27);
  for (int i = 1; i <= 1023; i++) {
    res = max(res, cal(i));
  }
  cout << res;
  return 0;
}
