#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[n][10];
  for (int i = (int)0; i < (int)n; ++i) {
    for (int j = (int)0; j < (int)10; ++j) cin >> f[i][j];
  }
  int p[n][11];
  for (int i = (int)0; i < (int)n; ++i) {
    for (int j = (int)0; j < (int)11; ++j) cin >> p[i][j];
  }
  long long ans = -10000010;
  for (int b = 1; b < (1 << 10); ++b) {
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      int count = 0;
      for (int j = 0; i < 10; ++j) {
        if ((b >> j) & 1 && f[i][j]) ++count;
      }
      sum += p[i][count];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
