#include <vector>
#include <string>
#include <iostream>
using namespace std;

void init(int N, vector<string> M) {
    
}

bool query(int h, int x, int y) {
    return false;
}

// GRADER DI ESEMPIO, NON MODIFICARE

#ifndef EVAL

int main() {
    int N, Q;
    cin >> N >> Q;
    
    vector<string> M(N);
    for (int i = 0; i < N; i++)
        cin >> M[i];
    
    init(N, M);

    for (int i = 0; i < Q; i++) {
        int h, x, y;
        cin >> h >> x >> y;
        cout << query(h, x, y) << '\n';
    }
}

#endif
