#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  vector<vector<int>> p(n, vector<int>(10));
  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 len = 1 << 10;
  int ans = -1000000009;
  for (int i = 0; i < len; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) {
      int x = i + 1;
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        if (x & 1) {
          if (f[j][k] == 1) {
            cnt++;
          }
        }
        x >> 1;
      }
      if (cnt != 0) tmp += p[j][cnt - 1];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
