#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[100] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 9; j >= 0; j--) {
      int tmp;
      cin >> tmp;
      f[i] += (tmp << j);
    }
  }
  int p[100][11];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1e8;
  for (int i = 1; i < (1 << 10); i++) {
    int point = 0;
    for (int j = 0; j < n; j++) {
      int tmp = f[j] & i;
      int c = 0;
      while (tmp > 0) {
        if (1 & tmp) c++;
        tmp = tmp >> 1;
      }
      point += p[j][c];
    }
    ans = max(ans, point);
  }
  cout << ans << endl;
}
