#include <bits/stdc++.h>
using namespace std;
int64_t pow(int64_t a, int64_t b) {
  if (b == 0) {
    return 1;
  } else {
    int64_t temp = pow(a, b / 2);
    temp = temp * temp;
    if (b % 2 == 1) {
      temp = temp * a;
    }
    return temp;
  }
}
class Digit {
 protected:
  int32_t m_base;
  std::vector<int32_t> m_digit;

 public:
  class WrongBaseException {};
  Digit(const int32_t base, const int64_t num) : m_base(base) {
    if (num < m_base) {
      m_digit.push_back(num);
    } else {
      int64_t copy_num = num;
      while (true) {
        int32_t temp = copy_num % m_base;
        m_digit.push_back(temp);
        copy_num = copy_num / base;
        if (copy_num < base) {
          m_digit.push_back(copy_num);
          break;
        }
      }
    }
  }
  Digit(const std::string& s) {
    m_base = 10;
    for (int64_t i = s.size() - 1; i >= 0; --i) {
      const char& c = s.at(i);
      switch (c) {
        case '0':
          m_digit.push_back(0);
          break;
        case '1':
          m_digit.push_back(1);
          break;
        case '2':
          m_digit.push_back(2);
          break;
        case '3':
          m_digit.push_back(3);
          break;
        case '4':
          m_digit.push_back(4);
          break;
        case '5':
          m_digit.push_back(5);
          break;
        case '6':
          m_digit.push_back(6);
          break;
        case '7':
          m_digit.push_back(7);
          break;
        case '8':
          m_digit.push_back(8);
          break;
        case '9':
          m_digit.push_back(9);
          break;
      }
    }
  }
  Digit(const int32_t base, const std::vector<int32_t> digit)
      : m_base(base), m_digit(digit) {}
  std::vector<int32_t>* getDigit() const {
    vector<int32_t>* retval = new vector<int32_t>(m_digit);
    return retval;
  }
  operator int64_t() const {
    int64_t ans = 0;
    for (std::vector<int32_t>::size_type i = 0; i < m_digit.size(); i++) {
      ans += pow(m_base, i) * m_digit.at(i);
    }
    return ans;
  }
  Digit& operator++() {
    (*this) += Digit(m_base, 1);
    return *this;
  }
  Digit& operator+=(const Digit& a) {
    if (m_base != a.m_base) {
      throw WrongBaseException();
    }
    std::vector<int32_t> copy = m_digit;
    m_digit.clear();
    int32_t carry_up = 0;
    for (std::vector<int32_t>::size_type i = 0;
         i < std::max(copy.size(), a.m_digit.size()); i++) {
      int32_t temp_digit = 0;
      if (i < copy.size()) {
        temp_digit += copy.at(i);
      }
      if (i < a.m_digit.size()) {
        temp_digit += a.m_digit.at(i);
      }
      temp_digit += carry_up;
      carry_up = temp_digit / m_base;
      m_digit.push_back(temp_digit % m_base);
    }
    if (carry_up != 0) {
      m_digit.push_back(carry_up);
    }
    return *this;
  }
  Digit operator+(const Digit& a) const {
    Digit retval(*this);
    retval += a;
    return retval;
    ;
  }
  Digit& operator-=(const Digit& a) {
    if (m_base != a.m_base) {
      throw WrongBaseException();
    }
    if (m_digit.size() < a.m_digit.size()) {
      throw std::underflow_error("Underflow in digit class");
    }
    std::vector<int32_t> copy = m_digit;
    m_digit.clear();
    int32_t carry_down = 0;
    for (std::vector<int32_t>::size_type i = 0; i < copy.size(); i++) {
      int32_t temp_digit = copy.at(i);
      if (i < a.m_digit.size()) {
        temp_digit -= a.m_digit.at(i);
      }
      temp_digit -= carry_down;
      if (temp_digit < 0) {
        temp_digit += m_base;
        carry_down = 1;
      } else {
        carry_down = 0;
      }
      m_digit.push_back(temp_digit);
    }
    if (carry_down > 0) {
      throw std::underflow_error("Underflow in digit class");
    }
    return *this;
  }
  Digit operator-(const Digit& a) const {
    Digit retval(*this);
    retval -= a;
    return retval;
    ;
  }
  Digit& operator--() {
    (*this) -= Digit(m_base, 1);
    return *this;
  }
};
int main() {
  int32_t n;
  cin >> n;
  int64_t** F = new int64_t*[n];
  int64_t** P = new int64_t*[n];
  for (int32_t i1 = 0; i1 < 10; i1++) {
    F[i1] = new int64_t[10];
    P[i1] = new int64_t[11];
  }
  for (int32_t i1 = 0; i1 < n; i1++) {
    for (int32_t i2 = 0; i2 < 10; i2++) {
      cin >> F[i1][i2];
    }
  }
  for (int32_t i1 = 0; i1 < n; i1++) {
    for (int32_t i2 = 0; i2 <= 10; i2++) {
      cin >> P[i1][i2];
    }
  }
  int64_t sum_of_match[n];
  int64_t ans = -10000000000000;
  for (Digit i1(2, 1); (long)i1 < pow(2, 10); ++i1) {
    vector<int32_t> digit = *(i1.getDigit());
    digit.resize(10);
    for (int32_t i2 = 0; i2 < n; i2++) {
      sum_of_match[i2] = 0;
    }
    for (int32_t i2 = 0; i2 < 10; i2++) {
      if (digit.at(i2) == 1) {
        for (int32_t i3 = 0; i3 < n; i3++) {
          if (F[i3][i2] == 1) {
            sum_of_match[i3]++;
          }
        }
      }
    }
    int64_t temp = 0;
    for (int32_t i2 = 0; i2 < n; i2++) {
      temp += P[i2][sum_of_match[i2]];
    }
    if (temp > ans) {
      ans = temp;
    }
  }
  cout << ans << endl;
}
