#include "timetravel.h"

#include <iostream>
#include <vector>

static const std::string PASSWORD = "i4ka_mi_dai_mi";

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int role;
    std::cin >> role;

    int N, T;
    std::cin >> N >> T;

    std::vector<int> a(T), b(T);
    for (int i = 0; i < T; i++) std::cin >> a[i] >> b[i];

    std::cout << PASSWORD << "\n";

    if (role == 0)
    {
        for (int i = 0; i < T; i++) std::cout << encode(N, a[i], b[i]) << "\n";
    }
    else
    {
        for (int i = 0; i < T; i++) std::cout << (answer(N, a[i], b[i]) ? 1 : 0) << "\n";
    }
    std::cout << std::flush;

    return 0;
}
