#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
vector<vector<int> > A, sum;
int ans[500][500];
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k, l, r, n, m, q;
  int sq = 400;
  cin >> n >> m;
  A.resize(n + 1);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> k, A[i].push_back(k);
  sum.resize(n + 1);
  for (i = 0; i < n + 1; i++) sum[i].resize(m + 1);
  for (j = 0; j < m; j++) {
    for (i = 1; i < n; i++) {
      if (A[i][j] < A[i - 1][j]) sum[i][j] = 1;
    }
  }
  for (i = 1; i < n; i++) {
    for (j = 0; j < m; j++) sum[i][j] += sum[i - 1][j];
  }
  cin >> q;
  if (m < sq) {
    while (q--) {
      cin >> l >> r;
      l--;
      r--;
      if (l == r) {
        cout << "Yes" << endl;
        continue;
      }
      for (i = 0; i < m; i++) {
        k = sum[r][i] - sum[l][i];
        if (k == 0) {
          cout << "Yes" << endl;
          break;
        }
      }
      if (i == m) cout << "No" << endl;
    }
  } else {
    for (j = 1; j < n; j++) {
      for (k = j; k < n; k++) {
        for (i = 0; i < m; i++) {
          if (sum[k][i] - sum[j - 1][i] == 0) ans[j][k] = 1;
        }
      }
    }
    while (q--) {
      cin >> l >> r;
      l--;
      r--;
      if (l == r) {
        cout << "Yes" << endl;
        continue;
      }
      if (ans[l + 1][r] == 1)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
  return 0;
}
