#include <bits/stdc++.h>
using namespace std;
int n;
const int NEGINF = -1 << 29;
vector<vector<int> > f, p;
int search(vector<int> a, int d, int m) {
  int res = 0;
  if (d == 10) {
    if (m == 0) {
      res = NEGINF;
    } else {
      for (int i = 0; i < (n); ++i) {
        res += p[i][a[i]];
      }
    }
  } else {
    res = search(a, d + 1, m);
    for (int i = 0; i < (n); ++i) {
      a[i] += f[i][d];
    }
    res = max(res, search(a, d + 1, m + 1));
  }
  return res;
}
int main() {
  cin >> n;
  f = vector<vector<int> >(n, vector<int>(10, 0));
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (10); ++j) {
      cin >> f[i][j];
    }
  }
  p = vector<vector<int> >(n, vector<int>(11, 0));
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (11); ++j) {
      cin >> p[i][j];
    }
  }
  vector<int> a(n, 0);
  cout << search(a, 0, 0) << endl;
  return 0;
}
