#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n;
int num[105];
int earn[1500];
int p[105][15];
int maxx = -9999999;
int getcount(int a, int b) {
  int c = (a & b);
  int ans = __builtin_popcount(c);
  return ans;
}
void read(int i) {
  int tmp;
  for (int j = 0; j < 10; j++) {
    scanf("%d", &tmp);
    num[i] = num[i] * 2 + tmp;
  }
}
int main() {
  memset(num, 0, sizeof(num));
  memset(earn, 0, sizeof(earn));
  for (int i = 0; i < (105); ++i)
    for (int j = 0; j < (15); ++j) p[i][j] = -99999999;
  cin >> n;
  for (int i = 0; i < n; i++) {
    read(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) scanf("%d", &p[i][j]);
  }
  int maxxi;
  for (int i = 1; i < 1024; i++) {
    for (int j = 0; j < n; j++) {
      earn[i] = earn[i] + p[j][getcount(i, num[j])];
    }
    if (earn[i] > maxx) {
      maxx = earn[i];
    }
  }
  cout << maxx << endl;
  return 0;
}
