#include <bits/stdc++.h>
using namespace std;
int n, ans = -1000000000;
int a[20], shift[100][10], interest[100][10];
void func() {
  int score = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (int j = 0; j < 10; j++) {
      if (shift[i][j] == 1 && a[i] == 1) count++;
    }
    score += interest[i][count];
  }
  ans = max(ans, score);
}
void dfs(int k) {
  if (k == 10) {
    int check = 0;
    for (int i = 0; i < 10; i++) {
      check += a[i];
    }
    if (check == 0) return;
    func();
    return;
  } else {
    a[k] = 0;
    dfs(k + 1);
    a[k] = 1;
    dfs(k + 1);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> shift[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> interest[i][j];
    }
  }
  dfs(0);
  cout << ans << endl;
}
