#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

typedef long long ll;

const int kMaxN = 100;
const int kInf = 1000000000;

int N;
int F[kMaxN][10];
int P[kMaxN][11];
int ans = -kInf;

// bool opened = false;

void Bfs(int j, vector<int> c) {
  if (j < 10) {
    Bfs(j+1, c);

    // opened = true;
    vector<int> c2(c);
    REP(i, N) { if (F[i][j]) { ++c2[i]; } }
    Bfs(j+1, c2);
    // opened = false;
  } else if (opened) {
    int ans2 = 0;
    REP(i, N) { ans2 += P[i][c[i]]; }
    ans = max(ans, ans2);
  }
  return;
}

int main() {
  cin >> N;
  REP(i, N) { REP(j, 10) { cin >> F[i][j]; } }
  REP(i, N) { REP(j, 11) { cin >> P[i][j]; } }

  vector<int> c(10, 0);
  Bfs(0, c);

  cout << ans << endl;
  return 0;
}
