#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
int main() {
  int n, f[100][10], p[100][11];
  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];
  int ans = -INF;
  for (int S = 1; S < 1024; S++) {
    int sum = 0;
    for (int i = 0; i < (n); i++) {
      int cnt = 0;
      for (int j = 0; j < (10); j++)
        if ((S >> j & 1) && f[i][j] == 1) cnt++;
      sum += p[i][cnt];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
