#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int f[100][10];
int p[100][11];
int s[10];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  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 int maxn = -1000000001;
  long long int tmp = 0;
  for (int i1 = 0; i1 < (2); i1++) {
    for (int i2 = 0; i2 < (2); i2++) {
      for (int i3 = 0; i3 < (2); i3++) {
        for (int i4 = 0; i4 < (2); i4++) {
          for (int i5 = 0; i5 < (2); i5++) {
            for (int i6 = 0; i6 < (2); i6++) {
              for (int i7 = 0; i7 < (2); i7++) {
                for (int i8 = 0; i8 < (2); i8++) {
                  for (int i9 = 0; i9 < (2); i9++) {
                    for (int i10 = 0; i10 < (2); i10++) {
                      if (i1 == 0 && i2 == 0 && i3 == 0 && i4 == 0 && i5 == 0 &&
                          i6 == 0 && i7 == 0 && i8 == 0 && i9 == 0 && i10 == 0)
                        continue;
                      int cnt = 0;
                      tmp = 0;
                      s[0] = i1;
                      s[1] = i2;
                      s[2] = i3;
                      s[3] = i4;
                      s[4] = i5;
                      s[5] = i6;
                      s[6] = i7;
                      s[7] = i8;
                      s[8] = i9;
                      s[9] = i10;
                      for (int i = 0; i < (n); i++) {
                        cnt = 0;
                        for (int j = 0; j < (10); j++) {
                          if (s[j] == 1 && f[i][j] == 1) {
                            cnt++;
                          }
                        }
                        tmp += p[i][cnt];
                      }
                      maxn = max(maxn, tmp);
                      cout << (maxn) << "\n";
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << (maxn) << "\n";
  return 0;
}
