#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int i, j, n, m, k, l, r;     cin >> n >> m;     int a[n][m];     pair<int, int> start_end[n][m];     for (i = 0; i < n; i += 1)       for (j = 0; j < m; j += 1) {         cin >> a[i][j];         start_end[i][j].first = i;         start_end[i][j].second = i;       }     for (j = 0; j < m; j += 1)       for (i = 1; i < n; i += 1)         if (a[i][j] >= a[i - 1][j])           start_end[i][j].first = start_end[i - 1][j].first;     int min_l[n];     for (i = 0; i < n; i++) min_l[i] = 100010;     for (i = 0; i < n; i += 1)       for (j = 0; j < m; j += 1)         if (start_end[i][j].first < min_l[i]) min_l[i] = start_end[i][j].first;     cin >> k;     while (k--) {       cin >> l >> r;       cout << ((min_l[r - 1] <= l - 1) ?  Yes n  :  No n );     }     return 0;   }   