#include <bits/stdc++.h>
using namespace std;
constexpr int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int F[100][14];
int P[100][15];
int main() {
  int N;
  cin >> N;
  for (int i = (int)(0); i < (int)(N); i++)
    for (int j = (int)(0); j < (int)(10); j++) cin >> F[i][j];
  for (int i = (int)(0); i < (int)(N); i++)
    for (int j = (int)(0); j < (int)(10); j++) cin >> P[i][j];
  int res = -(1 << 30);
  for (int bit = (int)(1); bit < (int)((1 << 10)); bit++) {
    int cc = 0;
    for (int i = (int)(0); i < (int)(N); i++) {
      int c = 0;
      for (int j = 0; j < 10; j++)
        if (((bit >> j) & 1) && F[i][j]) c++;
      cc += P[i][c];
    }
    if (res < cc) res = cc;
  }
  cout << res << endl;
  return 0;
}
