#include <bits/stdc++.h>
using namespace std;
int n;
int ent;
int main() {
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10, 0));
  vector<vector<int> > c(n, vector<int>(10, 0));
  vector<int> store(n, 0);
  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 < 10; j++) {
      cin >> c[i][j];
    }
    cin >> ent;
  }
  int max = -10000001;
  for (int bit = 1; bit < 1024; bit++) {
    int mask = 1;
    for (int i = 0; i < 10; i++) {
      if ((bit & mask) == mask) {
        for (int j = 0; j < n; j++) {
          store[j] = store[j] + f[j][i];
        }
      }
      mask = mask << 1;
    }
    int calc = 0;
    for (int j = 0; j < n; j++) {
      calc = calc + c[j][store[j]];
      store[j] = 0;
    }
    if (calc > max) {
      max = calc;
    }
  }
  cout << max << endl;
  return 0;
}
