#include <bits/stdc++.h>
using namespace std;
int binary[10];
int check[100];
void init(void) {
  for (int i = 0; i < 100; i++) {
    check[i] = 0;
  }
}
void ten_two(int x) {
  int sub = 1;
  for (int i = 0; i < 9; i++) {
    sub = sub * 2;
  }
  for (int i = 0; i < 10; i++) {
    if (x >= sub) {
      if (sub != 0) {
        binary[i] = 1;
      }
      x = x - sub;
    } else {
      binary[i] = 0;
    }
    sub = sub / 2;
  }
}
int main() {
  int N;
  cin >> N;
  int F[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  long long P[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  long long ans = -100000007;
  for (int a = 1; a <= 1023; a++) {
    init();
    ten_two(a);
    long long subsub = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 10; j++) {
        if (F[i][j] == 1 && binary[j] == 1) {
          check[i]++;
        }
      }
    }
    for (int i = 0; i < N; i++) {
      subsub = subsub + P[i][check[i]];
    }
    if (subsub > ans) {
      ans = subsub;
    }
  }
  cout << ans << endl;
}
