#include <bits/stdc++.h>
using namespace std;
int dy[4] = {0, 0, 1, -1};
int dx[4] = {1, -1, 0, 0};
int ans = 999999999 * (-1);
int a[20];
int N;
bool F[100][11];
long long P[100][11];
void func(void) {
  int score = 0;
  bool ok = false;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < 10; j++) {
      if (a[j] == 1) ok = true;
      if (F[i][j] == 1)
        if (a[j] == 1) cnt++;
    }
    score += P[i][cnt];
  }
  if (ok) ans = max(ans, score);
}
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;
}
