#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int open[105][10], profit[105][10];
int main() {
  int n;
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (10); ++j) {
      cin >> open[i][j];
    }
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (10); ++j) {
      cin >> profit[i][j];
    }
  }
  int ans = -1000000000;
  ;
  for (int bit = (1); bit < ((1 << 10)); ++bit) {
    int get = 0;
    for (int i = (0); i < (n); ++i) {
      int c = 0;
      for (int j = (0); j < (10); ++j) {
        if ((bit >> j & 1) & open[i][j]) c++;
      }
      get += profit[i][c];
    }
    chmax(ans, get);
  }
  cout << ans << "\n";
}
