#include <bits/stdc++.h>
using namespace std;
int n, s, ans = -1e9, d, k[105][15], l[105][15];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 10; ++j) {
      cin >> k[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> l[i][j];
    }
  }
  for (int bit = 1; bit < (1 << 10); ++bit) {
    for (int j = 0; j < 10; ++j) {
      k[0][j + 1] = bit & (1 << j);
    }
    s = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1, d = 0; j <= 10; ++j) {
        d += k[0][j] && k[i][j];
      }
      s += l[i][d];
    }
    ans = max(ans, s);
  }
  cout << ans << endl;
}
