#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int N;
bool shop[100][5 * 2];
LL joi[100][5 * 2];
int profit(int i, int j) {
  int count = 0;
  for (int k = 0; k < 10; ++k) {
    if (j & (1 << k) != 0 && shop[i][k]) {
      count++;
    }
  }
  return joi[i][count];
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> shop[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> joi[i][j];
    }
  }
  int ans = 0;
  bool cnt = true;
  for (int i = 0; i < (1 << 10); ++i) {
    int pro = 0;
    for (int j = 0; j < N; ++j) {
      pro += profit(j, i);
    }
    if (cnt) {
      ans = pro;
      cnt = false;
    } else {
      ans = max(pro, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
