#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int search(int key, vector<int> a) {
  int right = a.size();
  int left = 0;
  while (right >= left) {
    int middle = left + (right - left) / 2;
    if (a[middle] == key)
      return middle;
    else if (a[middle] > key)
      right = middle - 1;
    else if (a[middle] < key)
      left = middle + 1;
  }
  return -1;
}
int main() {
  int n;
  cin >> n;
  int f[n][10];
  int p[n][11];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -10000000;
  for (int check = 1; check < (1 << 10); check++) {
    int highScore = 0;
    for (int N = 0; N < n; N++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (((check >> j) & 1) && f[N][j]) cnt++;
      }
      highScore += p[N][cnt];
    }
    ans = (highScore > ans) ? highScore : ans;
  }
  cout << ans << endl;
  return 0;
}
