#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int N;
bool F[100][10] = {};
long long P[100][10] = {};
long long cum_P[100][10] = {};
long long maxincome = -2000000000;
void input(void) {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &F[i][j]);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      scanf("%lld", &P[i][j]);
    }
  }
}
void make_cum(void) {
  for (int i = 0; i < N; i++) {
    cum_P[i][0] = P[i][0];
    for (int j = 1; j < 10; j++) {
      cum_P[i][j] = cum_P[i][j - 1] + P[i][j];
    }
  }
}
struct Data_DFS {
  int sameday[100];
};
void dfs(Data_DFS data, int day) {
  if (day == 10) {
    bool countfrag = false;
    for (int i = 0; i < N; i++) {
      if (data.sameday[i] != 0) {
        countfrag = true;
        break;
      }
    }
    if (countfrag) {
      long long tempans = 0;
      for (int i = 0; i < N; i++) {
        tempans += P[i][data.sameday[i]];
      }
      if (tempans > maxincome) {
        maxincome = tempans;
      }
    }
  } else {
    dfs(data, day + 1);
    for (int i = 0; i < N; i++) {
      if (F[i][day] == 1) {
        data.sameday[i]++;
      }
    }
    dfs(data, day + 1);
  }
}
int main(void) {
  input();
  make_cum();
  Data_DFS pushdata;
  for (int i = 0; i < N; i++) {
    pushdata.sameday[i] = 0;
  }
  dfs(pushdata, 0);
  cout << maxincome << endl;
  return 0;
}
