#include <bits/stdc++.h>
using namespace std;
int main(void) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  long long max = -9999999999;
  int n, i;
  int f[101][11];
  long long p[101][11];
  cin >> n;
  for (i = 1; i <= n; i++) {
    int j;
    for (j = 1; j <= 10; j++) cin >> f[i][j];
  }
  for (i = 1; i <= n; i++) {
    int j;
    for (j = 0; j <= 10; j++) cin >> p[i][j];
  }
  for (int i1 = 0; i1 <= 1; i1++)
    for (int i2 = 0; i2 <= 1; i2++)
      for (int i3 = 0; i3 <= 1; i3++)
        for (int i4 = 0; i4 <= 1; i4++)
          for (int i5 = 0; i5 <= 1; i5++)
            for (int i6 = 0; i6 <= 1; i6++)
              for (int i7 = 0; i7 <= 1; i7++)
                for (int i8 = 0; i8 <= 1; i8++)
                  for (int i9 = 0; i9 <= 1; i9++)
                    for (int i10 = 0; i10 <= 1; i10++)
                      if ((i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10) !=
                          0) {
                        int j;
                        long long date[101];
                        long long answ = 0;
                        memset(date, 0, sizeof date);
                        for (j = 1; j <= n; j++) {
                          if ((f[j][1] == i1) && (i1 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][2] == i2) && (i2 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][3] == i3) && (i3 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][4] == i4) && (i4 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][5] == i5) && (i5 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][6] == i6) && (i6 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][7] == i7) && (i7 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][8] == i8) && (i8 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][9] == i9) && (i9 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          if ((f[j][10] == i10) && (i10 == 1)) date[j]++;
                        }
                        for (j = 1; j <= n; j++) {
                          answ = answ + p[j][date[j]];
                        }
                        if (answ > max) max = answ;
                      }
  cout << max;
  return 0;
}
