#include <bits/stdc++.h>
using namespace std;
int n;
struct lll {
  int x, a[11];
} TM[110];
int s[20] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
int main() {
  int n;
  cin >> n;
  int x;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = 0; j < 10; j++) {
      cin >> x;
      sum += s[j] * x;
    }
    TM[i].x = sum;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> TM[i].a[j];
    }
  }
  int MAX = -1e8;
  for (int i = 1; i < 1024; i++) {
    int sum = 0;
    for (int j = 1; j <= n; j++) {
      int q = (TM[j].x & i);
      int sum1 = 0;
      while (q != 0) {
        if (q % 2 == 1) sum1++;
        q /= 2;
      }
      sum += TM[j].a[sum1];
    }
    MAX = max(MAX, sum);
  }
  cout << MAX << endl;
  return 0;
}
