#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(11, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) cin >> p[i][j];
  }
  int ans = 0;
  for (int mask = 1; mask < (1 << 10); mask++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if (mask & (1 << j) && a[i][j]) c++;
      }
      cnt += p[i][c];
    }
    ans = max(ans, cnt);
  }
  cout << ans;
}
