#include <bits/stdc++.h>
using namespace std;
vector<bool> V(10, false);
void change(int n, vector<bool> &V) {
  int i = 0;
  while (n > 0) {
    int x;
    x = n % 2;
    V[i] = x;
    n /= 2;
    i++;
  }
}
int main() {
  int N;
  cin >> N;
  int ans = 0;
  vector<vector<bool>> inf(100, vector<bool>(10, false));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int F;
      cin >> F;
      if (F == 1) {
        inf[i][j] = true;
      }
    }
  }
  vector<vector<int>> benefit(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int P;
      cin >> P;
      benefit[i][j] = P;
    }
  }
  for (int i = 1; i < 1024; i++) {
    vector<bool> V(10, false);
    change(i, V);
    int sum = 0;
    for (int j = 0; j < N; j++) {
      int counter = 0;
      for (int k = 0; k < 10; k++) {
        if (V[k] == true && inf[j][k] == true) {
          counter++;
        }
      }
      sum += benefit[j][counter];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
