#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> vec(n, vector<int>(10));
  vector<vector<int>> vec2(n, vector<int>(11));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(10); j++) cin >> vec[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) cin >> vec2[i][j];
  ll ans = -100000000;
  for (int i = 0; i < (int)(1 << 10); i++) {
    if (i == 0) continue;
    bitset<10> bit(i);
    ll score = 0;
    for (int i = 0; i < (int)(n); i++) {
      int cnt = 0;
      for (int j = 0; j < (int)(10); j++)
        if (bit.test(j) && vec[i][j] == 1) cnt++;
      score += vec2[i][cnt];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
}
