#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<int>> F(n, vector<int>(10));
  vector<vector<int>> P(n, vector<int>(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 = -1000000;
  for (int bit = 1; bit < (1 << 10); bit++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if ((bit >> j & 1) && F[i][9 - j] == 1) cnt++;
      }
      sum += P[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
