#include <bits/stdc++.h>
using namespace std;
static const int MAX = 101;
int N;
int F[MAX][11];
int P[MAX][11];
int main(int argc, const char* argv[]) {
  int i, j;
  cin >> N;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= 10; j++) {
      cin >> F[i][j];
    }
  }
  for (i = 1; i <= N; i++) {
    for (j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  int ans = -999999999;
  for (int a = 0; a <= 1; a++) {
    for (int b = 0; b <= 1; b++) {
      for (int c = 0; c <= 1; c++) {
        for (int d = 0; d <= 1; d++) {
          for (int e = 0; e <= 1; e++) {
            for (int f = 0; f <= 1; f++) {
              for (int g = 0; g <= 1; g++) {
                for (int h = 0; h <= 1; h++) {
                  for (int k = 0; k <= 1; k++) {
                    for (int l = 0; l <= 1; l++) {
                      int R[] = {a, b, c, d, e, f, g, h, k, l};
                      int tmp = 0;
                      for (i = 1; i <= N; i++) {
                        int count = 0;
                        for (j = 1; j <= 10; j++) {
                          if (F[i][j] && R[j]) {
                            count++;
                          }
                        }
                        tmp += P[i][count];
                      }
                      ans = max(ans, tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
