#include <bits/stdc++.h>
using namespace std;
namespace CsF {
string ConvertBit(int N, int e) {
  string s = "";
  int r = 0;
  while (N != 0) {
    r = N % e;
    s = to_string(r) + s;
    N -= r;
    N /= e;
  }
  return s;
}
}  // namespace CsF
using namespace CsF;
int main() {
  int N;
  cin >> N;
  array<array<int, 10>, 100> F;
  array<array<int, 11>, 100> P;
  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 < 11; j++) cin >> P[i][j];
  }
  array<int, 10> box;
  string s;
  int max = 0;
  int ans = INT_MIN;
  int count = 0;
  for (int bit = 1; bit < 1024; bit++) {
    s = ConvertBit(bit, 2);
    for (int i = s.length(); i < 10; i++) {
      s = "0" + s;
    }
    for (int i = 0; i < 10; i++) {
      box[i] = stoi(string() + s[i]);
    }
    for (int i = 0; i < N; i++) {
      count = 0;
      for (int j = 0; j < 10; j++) {
        if (box[j] == F[i][j] && box[j] == 1) count++;
      }
      max += P[i][count];
    }
    if (ans < max) ans = max;
    max = 0;
  }
  cout << ans << endl;
  return 0;
}
