#include <bits/stdc++.h>
using namespace std;
long long ans = -999999999999;
int a[25];
int N;
bool F[100][11];
long long P[100][11];
void func(void) {
  long long sco = 0;
  bool abc = false;
  for (int i = 0; i < N; i++) {
    int abcd = 0;
    for (int j = 0; j < 10; j++) {
      if (a[j] == 1) abc = true;
      if (F[i][j] == 1)
        if (a[j] == 1) abcd++;
    }
    sco += P[i][abcd];
  }
  if (abc) ans = max(ans, sco);
}
void dfs(int pos) {
  if (pos == 10) {
    func();
    return;
  }
  a[pos] = 0;
  dfs(pos + 1);
  a[pos] = 1;
  dfs(pos + 1);
}
int main() {
  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 << ans << endl;
}
