#include <bits/stdc++.h>
using namespace std;
string toBinary(long long x, int n) {
  string s;
  while (x != 0) {
    int r = abs(x % n);
    s += to_string(r);
    x -= r;
    x /= n;
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> F;
  vector<vector<int>> P;
  F.resize(N);
  P.resize(N);
  for (int i = 0; i < N; i++) {
    F[i].resize(10);
    P[i].resize(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 = -1000000000;
  for (int i = 1; i < (1 << 10); i++) {
    string b = toBinary(i, 2);
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      int num = 0;
      for (int k = 0; k < 10; k++) {
        if ((b[k] - '0') == 1 && F[j][k] == 1) {
          num++;
        }
      }
      tmp += P[j][num];
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
