#include <bits/stdc++.h>
using namespace std;
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];
    }
  }
  string s;
  int ans = -100000000;
  int sum = 0;
  int c[n];
  for (int i = 1; i <= 1023; i++) {
    for (int l = 0; l < n; l++) c[l] = 0;
    stringstream jo;
    jo << static_cast<std::bitset<10>>(i);
    s = jo.str();
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 10; k++) {
        if (s[k] == '1' && f[j][k] == 1) c[j]++;
      }
    }
    for (int i = 0; i < n; i++) {
      sum += p[i][c[i]];
    }
    ans = max(sum, ans);
    sum = 0;
  }
  cout << ans << endl;
}
