#include "testlib.h"
#include "bits/stdc++.h"

using namespace std;
const int MAXN = 100, MAXM = MAXN, MAXK = MAXN, MAXQ = 1;

vector <pair<int, int>> places[MAXN];

int main() {    
    registerValidation();
    
    int n = inf.readInt(2, MAXN); inf.readSpace();
    int m = inf.readInt(0, MAXM); inf.readSpace();
    int k = inf.readInt(1, MAXK);
    inf.readEoln();

    for (int i = 0; i < m; ++i) {
        int s = inf.readInt(1, n); inf.readSpace();
        int t = inf.readInt(s + 1, n); inf.readSpace();
        int a = inf.readInt(1, k);
        places[a - 1].push_back(make_pair(s - 1, t - 1));
        inf.readEoln();
    }

    for (int i = 0; i < k; ++i) {
        sort(places[i].begin(), places[i].end());
        for (int j = 1; j < (int) places[i].size(); ++j) {
            ensure(places[i][j].first >= places[i][j - 1].second);
        }
    }

    int q = inf.readInt(1, MAXQ);
    inf.readEoln();
    
    for (int i = 0; i < q; ++i) {
        int f = inf.readInt(1, n); inf.readSpace();
        int d = inf.readInt(f + 1, n);
        inf.readEoln();
    }

    inf.readEof();
    return 0;
}