#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main() {
  int n;
  cin >> n;
  ll f[n][10];
  for (int i = int(0); i < int(n); i += 1)
    for (int j = int(0); j < int(10); j += 1) cin >> f[i][j];
  ll p[n][11];
  for (int i = int(0); i < int(n); i += 1)
    for (int j = int(0); j < int(11); j += 1) cin >> p[i][j];
  ll ans = -(1 << 60);
  for (int i = int(1); i < int(1 << 10); i += 1) {
    ll data[n];
    for (int j = int(0); j < int(n); j += 1) data[j] = 0;
    for (int j = int(0); j < int(10); j += 1) {
      if (i & 1 << j) {
        for (int k = int(0); k < int(n); k += 1)
          if (f[k][j] == 1) data[k]++;
      }
    }
    ll count = 0;
    for (int j = int(0); j < int(n); j += 1) count += p[j][data[j]];
    if (ans < count) ans = count;
  }
  cout << ans << endl;
}
