#include <bits/stdc++.h>
using namespace std;
int N;
int F[110][12];
int P[110][12];
int change(int n) {
  int b = 0;
  int base = 1;
  while (n > 0) {
    b += (n % 2) * base;
    n = n / 2;
    base *= 10;
  }
  return b;
}
int main() {
  while (cin >> N && N > 0) {
    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];
      }
    }
    long long ans = -1000000;
    for (int i = 1; i < 1024; i++) {
      long long ansnow = 0;
      string s = to_string(change(i));
      int open[12] = {0};
      for (int j = 0; j < 10; j++) {
        if (&s[i] == "1")
          open[i] = 1;
        else
          open[j] = 0;
      }
      for (int j = 0; j < N; j++) {
        int count = 0;
        for (int k = 0; k < 10; k++) {
          if (open[i] == 1 && F[j][k] == 1) count++;
        }
        ansnow += P[j][count];
      }
      ans = max(ans, ansnow);
    }
    cout << ans << endl;
  }
}
