#include <algorithm>
#include <iostream>
#include "tree.h"

namespace {
  constexpr int H = 15, N = 1 << H;
  constexpr int FULL_SCORE[3] = {0, 10, 90};
  int subtask, current_testcase;
  void report_result(int score, const std::string& msg) {
    std::cerr << "Result: " << score << " / " << FULL_SCORE[subtask] << " points" << std::endl;
    std::cerr << msg;
    if (current_testcase) std::cerr << " (test case " << current_testcase << ")";
    std::cerr << std::endl;
    exit(0);
  }

  int h, n, p[N], w[N], dep[N];
  long long f[H * 2 - 1][N], s[N];
  int cost, cnt[N];

  inline long long calc(int u, int d) {
    if (dep[u] + d >= h) return 0;
    return s[((u + 1) << d) - 1] - s[(u << d) - 1];
  }
  void init() {
    for (int i = 1; i <= n; i++) s[i] = s[i - 1] + w[i];
    for (int d = 1; d <= h * 2 - 2; d++) {
      for (int u = 1; u <= n; u++) {
        long long &sum = f[d][u] = calc(u, d);
        int min_jump = std::max(d - (h - 1 - dep[u]) - 2, 0) / 2;
        for (int x = u >> min_jump, i = d - 1 - min_jump; x > 1 && i >= 0; x >>= 1, i--) {
          if (i) sum += calc(x ^ 1, i - 1);
          else sum += w[x >> 1];
        }
      }
    }
  }
}

long long ask(int u, int d) {
  cost++, cnt[u]++;
  if (cost > n * h * 2) {
    #ifdef DEBUG
    std::cerr << "ask: u = " << u << ", d = " << d << std::endl;
    #endif
    report_result(0, "Too many queries");
  }
  if (u < 1 || u > n || d <= 0 || d > 1E9) {
    #ifdef DEBUG
    std::cerr << "ask: u = " << u << ", d = " << d << std::endl;
    #endif
    report_result(0, "Invalid query");
  }
  #ifdef DEBUG
  std::cerr << "ask: u = " << u << ", d = " << d << ", return " << (d > h * 2 - 2 ? 0 : f[d][p[u]]) << std::endl;
  #endif
  return d > h * 2 - 2 ? 0 : f[d][p[u]];
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  for (int i = 2; i < N; i++) dep[i] = dep[i / 2] + 1;
  int T;
  std::cin >> subtask >> T;
  int final_score = 90, final_case = -1;
  for (int c = 1; c <= T; c++) {
    current_testcase = c;
    std::cin >> h;
    n = (1 << h) - 1;
    std::fill_n(cnt + 1, n, 0), cost = 0;
    for (int i = 1; i <= n; i++) std::cin >> p[i];
    for (int i = 1; i <= n; i++) std::cin >> w[i];
    init();
    long long jans = 0, pans = solve(subtask, h);
    for (int i = 1; i <= n; i++) jans += w[i];
    if (jans != pans) report_result(0, "Read " + std::to_string(pans) + ", expected " + std::to_string(jans));
    int max_cnt = *std::max_element(cnt + 1, cnt + 1 + n);
    int score;
    if (cost <= 2 * n + 3) score = 90;
    else if (cost <= 2 * n + 4) score = 82;
    else if (cost <= 2 * n + 5) score = 76;
    else if (cost <= 2 * n + h + 2) score = 72;
    else if (cost <= 2 * n + h + 4) score = 69;
    else if (cost <= 2 * n + 2 * h + 2) score = 66;
    else if (cost <= 2 * n + 2 * h + 4) score = 63;
    else if (cost <= 3 * n + 3) score = 59;
    else if (cost <= 3 * n + 5) score = 56;
    else if (cost <= 3 * n + h + 4) score = 53;
    else if (cost <= 3 * n + 2 * h + 4) score = 50;
    else if (cost <= 4 * n + 3) score = 43;
    else if (cost <= 4 * n + 5) score = 40;
    else if (cost <= 4 * n + h + 4) score = 37;
    else if (cost <= 4 * n + 2 * h + 4) score = 34;
    else score = 30;
    if (max_cnt > 6) score -= 20;
    else if (max_cnt == 6) score -= 15;
    else if (max_cnt == 5) score -= 10;
    if (score < final_score) {
      final_score = score;
      final_case = current_testcase;
    }
    #ifdef DEBUG
    std::cerr << "max_cnt = " << max_cnt << ", cost = " << cost << ", score = " << score << std::endl;
    #endif
  }
  current_testcase = 0;
  if (subtask == 1) report_result(10, "Correct");
  else if (final_score == 90) report_result(90, "Correct");
  else {
    current_testcase = final_case;
    report_result(final_score, "Partially correct");
  }
  return 0;
}
