#include <bits/stdc++.h>
const long long int INF = 1e9;
using namespace std;
struct Point {
  int x, y;
};
bool vector_finder(std::vector<long long int> vec, long long int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return true;
  } else {
    return false;
  }
}
long long int factorial(long long int N) {
  long long int ans = 1;
  for (long long int i = 1; i <= (long long int)(N); i++) {
    ans *= i;
  }
  return ans;
}
long long int extended_factorial(long long int N) {
  long long int ans = 1;
  for (long long int i = 1; i <= (long long int)(N); i++) {
    ans *= i;
    ans %= (long long int)(1e9 + 7);
  }
  return ans;
}
vector<long long int> Eratosthenes(long long int N) {
  bool arr[N + 1];
  arr[0] = false;
  arr[1] = false;
  for (long long int i = 2; i < N + 1; i++) {
    arr[i] = true;
  }
  for (long long int i = 2; i <= sqrt(N); i++) {
    if (arr[i]) {
      for (long long int j = 0; i * (j + 2) <= N; j++) {
        arr[i * (j + 2)] = false;
      }
    }
  }
  vector<long long int> prime;
  for (long long int i = 1; i <= (long long int)(N); i++) {
    if (arr[i] == true) {
      prime.push_back(i);
    }
  }
  return prime;
}
char alphabet[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                   'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                   's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int main() {
  int N;
  cin >> N;
  bool F[102][12];
  int P[102][12];
  for (int i = 0; i < (int)(102); i++) {
    for (int j = 0; j < (int)(12); j++) {
      F[i][j] = false;
      P[i][j] = false;
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(10); j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(11); j++) {
      cin >> P[i][j];
    }
  }
  int max = -10000001;
  int n = 10;
  bool isOpen[10];
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool isOpenTime = false;
    for (int i = 0; i < (int)(10); i++) isOpen[i] = false;
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        isOpen[i] = true;
        isOpenTime = true;
      }
    }
    if (isOpenTime) {
      int sum = 0, c;
      for (int i = 0; i < (int)(N); i++) {
        c = 0;
        for (int j = 0; j < (int)(n); j++) {
          if (isOpen[j] && F[i][j]) c++;
        }
        sum += P[i][c];
      }
      if (sum > max) {
        max = sum;
      }
    }
  }
  cout << max << endl;
  return 0;
}
