#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool isopen[100][10];
  int kari;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &kari);
      if (kari)
        isopen[i][j] = true;
      else
        isopen[i][j] = false;
    }
  }
  int profit[100][11];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) scanf("%d", &profit[i][j]);
  }
  int flag = 1;
  int ans = -10000000;
  while (flag < 1024) {
    int ryoueigyou[100] = {};
    for (int i = 0; i < 10; i++) {
      if ((flag & (1 << i))) {
        for (int j = 0; j < n; j++) {
          if (isopen[j][i]) ryoueigyou[j] += 1;
        }
      }
    }
    int tmp_ans = 0;
    for (int j = 0; j < n; j++) {
      tmp_ans += profit[j][ryoueigyou[j]];
    }
    if (ans < tmp_ans) ans = tmp_ans;
    flag += 1;
  }
  cout << ans << endl;
}
