#include <bits/stdc++.h>
using namespace std;
int f[110][10], n, p[110][11], res = -1100000000, g[10];
void dfs(int x) {
  if (x == 5) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int cou = 0;
      for (int j = 0; j < 10; j++) {
        if (g[j] == 1 && f[i][j] == 1) cou++;
      }
      ans += p[i][cou];
    }
    res = max(ans, res);
  } else {
    g[x] = 1, g[x + 5] = 0;
    dfs(x + 1);
    g[x] = 0, g[x + 5] = 1;
    dfs(x + 1);
    g[x] = 1, g[x + 5] = 1;
    dfs(x + 1);
  }
}
int main(void) {
  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];
    }
  }
  dfs(0);
  cout << res << endl;
}
