#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  vector<vector<int> > p(n, vector<int>(11, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 10; j++) cin >> p[i][j];
  int ma = -1000000000;
  int bits = pow(2, 10);
  for (int i = 1; i < bits; i++) {
    bitset<10> bit(i);
    vector<int> v(n);
    for (int j = 0; j < 10; j++) {
      if (bit[j]) {
        for (int k = 0; k < n; k++) {
          v[k] += f[k][j];
        }
      }
    }
    int ma_sub = 0;
    for (int l = 0; l < n; l++) {
      ma_sub += p[l][v[l]];
    }
    ma = max(ma, ma_sub);
  }
  cout << ma << endl;
}
