#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> shops;
  vector<vector<long>> profits;
  for (int i = 0; i < N; ++i) {
    vector<int> shop(10);
    for (int j = 0; j < 10; ++j) {
      cin >> shop[j];
    }
    shops.push_back(shop);
  }
  for (int i = 0; i < N; ++i) {
    vector<long> profit(11);
    for (int j = 0; j < 11; ++j) {
      cin >> profit[j];
    }
    profits.push_back(profit);
  }
  long max_profit = LONG_MIN;
  vector<int> num_of_opens_for_each_shop(N);
  for (int i = 1; i < 1024; ++i) {
    for (int j = 0; j < N; ++j) {
      num_of_opens_for_each_shop[j] = 0;
    }
    long sum = 0;
    bitset<10> pattern = bitset<10>((unsigned long long)i);
    for (int j = 0; j < 10; ++j) {
      if (pattern[j]) {
        for (int k = 0; k < N; ++k) {
          if (shops[k][j]) ++num_of_opens_for_each_shop[k];
        }
      }
    }
    for (int j = 0; j < N; ++j) {
      sum += profits[j][num_of_opens_for_each_shop[j]];
    }
    max_profit = max(max_profit, sum);
  }
  cout << max_profit << endl;
  return 0;
}
