#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = -1e9 + 7, tmp;
  scanf("%d", &n);
  vector<vector<int> > f(n, vector<int>(10)), p(n, vector<int>(11));
  vector<int> cnt(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) scanf("%d", &f[i][j]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) scanf("%d", &p[i][j]);
  }
  for (int i = 1; i < (1 << 10); i++) {
    tmp = 0;
    fill(cnt.begin(), cnt.end(), 0);
    for (int j = 0; j < 10; j++) {
      if (!(i & (1 << j))) continue;
      for (int k = 0; k < n; k++) {
        if (f[k][j] == 1) cnt[k] += 1;
      }
    }
    for (int j = 0; j < n; j++) tmp += p[j][cnt[j]];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
