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