#include <bits/stdc++.h>
using namespace std;
int mycount[110];
bool S[10], flag = true;
long long ans = -10000000000, P[110][10], temp;
bool F[110][10];
int N;
void solve() {
  for (int i = 0; i < N; i++) mycount[i] = 0;
  for (int i = 0; i < 10; i++) {
    if (S[i] == 1) {
      for (int j = 0; j < N; j++)
        if (F[j][i] == 1) mycount[j]++;
    }
  }
  for (int i = 0; i < N; i++) {
    temp += P[i][mycount[i]];
  }
  ans = max(ans, temp);
  temp = 0;
}
void set(int x) {
  if (x == 10) {
    if (flag) {
      flag = false;
      return;
    }
    solve();
    return;
  }
  S[x] = 0;
  set(x + 1);
  S[x] = 1;
  set(x + 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 < 10; j++) cin >> P[i][j];
  }
  set(0);
  cout << ans << endl;
}
