#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, f[101][12], p[101][12];
  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 <= 10; ++j) {
      cin >> p[i][j];
    }
  }
  int m = -1e9;
  for (int bit = 1; bit < 1 << 10; ++bit) {
    int cnt_flag = 0;
    for (int i = 0; i < 10; ++i) {
      if (bit & (1 << i)) cnt_flag++;
    }
    if (cnt_flag <= 1) continue;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      int cnt = 0;
      for (int j = 0; j < 10; ++j) {
        if (bit & (1 << j) && f[i][j]) cnt++;
      }
      ans += p[i][cnt];
    }
    m = max(m, ans);
  }
  cout << m << endl;
  return 0;
}
