#include <bits/stdc++.h>
using namespace std;
const long long MOD_CONST = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int benefit = -100000000;
  for (int i = 1; i < (1 << 10); i++) {
    int b = 0;
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        bool isOpen = (i >> k) & 1;
        if (isOpen && (f[j][k] == 1)) {
          cnt++;
        }
      }
      b += p[j][cnt];
    }
    if (benefit < b) {
      benefit = b;
    }
  }
  cout << benefit << endl;
}
