#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
using namespace std;
int n, ans = -1e9;
int a[105][15], w[105][15];
int k[15];
void dfs(int x, int f) {
  if (x > 10) {
    int m = 0, s = 0;
    for (int l = 1; l <= n; l++) {
      m = 0;
      for (int i = 1; i <= 10; i++)
        if (k[i] == 1 && a[l][i] == 1) m++;
      s += w[l][m + 1];
    }
    ans = max(ans, s);
    return;
  }
  if (x % 2 == 0 && f == 1 || x % 2 == 1) {
    k[x] = 1;
    dfs(x + 1, 1);
    k[x] = 0;
    dfs(x + 1, 0);
  } else {
    k[x] = 1;
    dfs(x + 1, 1);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) cin >> a[i][j];
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) cin >> w[i][j];
  dfs(1, 1);
  cout << ans;
  return 0;
}
