#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int> > shops(N, vector<int>(10));
  vector<vector<int> > benefit(N, vector<int>(11));
  int earn[10] = {0};
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 10; j++) cin >> shops[i][j];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 11; j++) cin >> benefit[i][j];
  int ans = -10000001;
  for (int i = 0; i < 0b1111111111; i++) {
    vector<int> a(N, 0);
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < 10; k++) {
        if (i & (shops[j][k] * int(pow(2, k)))) a[j]++;
      }
    }
    int temp = 0;
    for (int j = 0; j < N; j++) {
      temp += benefit[j][a[j]];
    }
    if (ans < temp) ans = temp;
  }
  cout << ans << endl;
  return 0;
}
