#include <bits/stdc++.h>
using namespace std;
int n;
int F[110][15];
int f[110];
int P[110][15];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    int sum = 0;
    int pos = 0;
    for (int j = 9; j >= 0; --j) {
      if (F[i][j]) {
        sum += pow(2, pos);
      }
      pos++;
    }
    f[i] = sum;
  }
  int ans = -1e9 + 7;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int ansc = 0;
    for (int i = 0; i < n; ++i) {
      int cnt = 0;
      int check = (bit & f[i]);
      for (int j = 0; j < 10; ++j) {
        if (check & (1 << j)) cnt++;
      }
      ansc += P[i][cnt];
    }
    ans = max(ans, ansc);
  }
  cout << ans << endl;
}
