func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[111][111][11], n, q, c, x, y, rx, ry, t, v;   int main() {     cin >> n >> q >> c;     for (int i = 1; i <= n; i++) {       cin >> x >> y >> t;       a[x][y][t]++;     }     for (int l = 0; l <= c; l++) {       for (int i = 1; i <= 100; i++)         for (int j = 1; j <= 100; j++) a[i][j][l] += a[i][j - 1][l];       for (int i = 1; i <= 100; i++)         for (int j = 1; j <= 100; j++) a[i][j][l] += a[i - 1][j][l];     }     for (int i = 1; i <= q; i++) {       v = 0;       cin >> t >> x >> y >> rx >> ry;       for (int j = 0; j <= c; j++)         v += (j + t) % (c + 1) *              (a[rx][ry][j] - a[rx][y - 1][j] - a[x - 1][ry][j] +               a[x - 1][y - 1][j]);       cout << v << endl;     }     return 0;   }   