#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
int main() {
  int n, ans = -100000000;
  cin >> n;
  vector<int> shop(n, 0);
  for (int i = 0; i < (int)n; ++i) {
    for (int j = 0; j < (int)10; ++j) {
      int x;
      cin >> x;
      shop[i] += pow(2, j) * x;
    }
  }
  int P[10][11];
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)11; ++j) cin >> P[i][j];
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int res = 0;
    for (int i = 0; i < (int)n; ++i) {
      int tmp = bit & shop[i];
      int cnt = 0;
      for (int j = 0; j < (int)10; ++j) {
        if (tmp & (1 << j)) cnt++;
      }
      res += P[i][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
