#include <bits/stdc++.h>
using namespace std;
int main() {
  int totaltime = 10;
  int n;
  cin >> n;
  int timetable[n][totaltime];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < totaltime; j++) {
      cin >> timetable[i][j];
    }
  }
  int profit[n][totaltime + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (totaltime + 1); j++) {
      cin >> profit[i][j];
    }
  }
  int ans = 0;
  for (int p = 0; p < pow(2, totaltime); p++) {
    int max_profit = 0;
    for (int i = 0; i < n; i++) {
      int match_count = 0;
      for (int j = 0; j < totaltime; j++) {
        if ((p >> j & 1) == 1 && timetable[i][j] == 1) {
          match_count += 1;
        }
      }
      max_profit += profit[i][match_count];
    }
    if (ans < max_profit) {
      ans = max_profit;
    }
  }
  cout << ans << endl;
}
