#include <bits/stdc++.h>
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  int shop;
  scanf("%d", &shop);
  int open[101][11];
  for (int i = 1; i <= shop; ++i) {
    for (int j = 1; j <= 10; ++j) {
      scanf("%d", &open[i][j]);
    }
  }
  int p[101][11];
  for (int i = 1; i <= shop; ++i) {
    for (int j = 0; j <= 10; ++j) {
      scanf("%d", &p[i][j]);
    }
  }
  long long int ans = -99999999;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int tmp = 0;
    int morning = 0;
    int afternoon = 0;
    int condition = 1;
    for (int i = 0; i < 10; ++i) {
      if ((bit >> i) & 1) {
        if (i % 2 == 0)
          morning = 1;
        else
          afternoon = 1;
      }
      if (i % 2 == 1) {
        if (morning == 0 && afternoon == 0) {
          condition = 0;
        }
        morning = 0;
        afternoon = 0;
      }
    }
    if (condition == 1) {
      for (int i = 1; i <= shop; ++i) {
        int shop_count = 0;
        for (int j = 1; j <= 10; ++j) {
          if ((((bit >> (j - 1)) & 1) == 1) && open[i][j] == 1) {
            shop_count++;
          }
        }
        tmp += p[i][shop_count];
      }
      ans = max(ans, tmp);
    }
  }
  printf("%d", ans);
}
