#include <bits/stdc++.h>
using namespace std;
const int NEGINF = -1 << 29;
vector<vector<int> > f, p;
int search(vector<int> a, int d, int n, int z) {
  int x, y;
  if (d == 10) {
    int res = 0;
    if (z == 10) {
      res = NEGINF;
    } else {
      for (int i = 0; i < (n); ++i) {
        res += p[i][a[i]];
      }
    }
    return res;
  } else {
    x = search(a, d + 1, n, z + 1);
    for (int i = 0; i < (n); ++i) {
      if (f[i][d]) a[i]++;
    }
    y = search(a, d + 1, n, z);
  }
  return max(x, y);
}
int main() {
  int n;
  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, n, 0) << endl;
  return 0;
}
