#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using vt = vector<T>;
template <class T>
using vvt = vector<vt<T>>;
template <class T>
using ttt = tuple<T, T>;
using tii = tuple<int, int>;
using vi = vector<int>;
const int INF = 200000000;
int f[100][10] = {};
int p[100][11] = {};
int ans = -INF;
int n;
int now[100] = {};
int dfs(int index, bool check) {
  if (index == 10 && check) {
    int t_ans = 0;
    for (int i = 0; i < (int)(n); i++) {
      t_ans += (p[i][now[i]]);
    }
    ans = max(ans, t_ans);
    return 0;
  } else if (index == 10 && check == 0)
    return 0;
  dfs(index + 1, check);
  for (int i = 0; i < (int)(n); i++) {
    if (f[i][index] == 1) now[i]++;
  }
  dfs(index + 1, 1);
  for (int i = 0; i < (int)(n); i++) {
    if (f[i][index] == 1) now[i]--;
  }
  return 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(10); j++) cin >> f[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(11); j++) cin >> p[i][j];
  dfs(0, 0);
  cout << ans << endl;
}
