description: The problem statement looms below, filling you with determination.
  
  Consider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell itself, so all filled in cells are not exitable. Note that you can exit the grid from any leftmost empty cell (cell in the first column) by going left, and from any topmost empty cell (cell in the first row) by going up.
  
  Let's call a grid determinable if, given only which cells are exitable, we can exactly determine which cells are filled in and which aren't.
  
  You are given a grid a of dimensions n × m , i. e. a grid with n rows and m columns. You need to answer q queries (1 ≤ q ≤ 2 ⋅ 10^5). Each query gives two integers x_1, x_2 (1 ≤ x_1 ≤ x_2 ≤ m) and asks whether the subgrid of a consisting of the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.
  
  Input
  
  The first line contains two integers n, m (1 ≤ n, m ≤ 10^6, nm ≤ 10^6) — the dimensions of the grid a.
  
  n lines follow. The y-th line contains m characters, the x-th of which is 'X' if the cell on the intersection of the the y-th row and x-th column is filled and "." if it is empty.
  
  The next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.
  
  q lines follow. Each line contains two integers x_1 and x_2 (1 ≤ x_1 ≤ x_2 ≤ m), representing a query asking whether the subgrid of a containing the columns x_1, x_1 + 1, …, x_2 - 1, x_2 is determinable.
  
  Output
  
  For each query, output one line containing "YES" if the subgrid specified by the query is determinable and "NO" otherwise. The output is case insensitive (so "yEs" and "No" will also be accepted).
  
  Example
  
  Input
  
  
  4 5
  ..XXX
  ...X.
  ...X.
  ...X.
  5
  1 3
  3 3
  4 5
  5 5
  1 5
  
  
  Output
  
  
  YES
  YES
  NO
  YES
  NO
  
  Note
  
  For each query of the example, the corresponding subgrid is displayed twice below: first in its input format, then with each cell marked as "E" if it is exitable and "N" otherwise.
  
  For the first query: 
      
      
        
      ..X EEN  
      ... EEE  
      ... EEE  
      ... EEE  
      
      
      
        
        
      
  
  For the second query: 
      
      
        
      X N  
      . E  
      . E  
      . E  
      
  
  Note that you can exit the grid by going left from any leftmost cell (or up from any topmost cell); you do not need to reach the top left corner cell to exit the grid.
      
      
        
        
      
  
  For the third query: 
      
      
        
      XX NN  
      X. NN  
      X. NN  
      X. NN  
      
  
  This subgrid cannot be determined only from whether each cell is exitable, because the below grid produces the above "exitability grid" as well: 
      
      
        
      XX  
      XX  
      XX  
      XX  
      
      
      
        
        
      
  
  For the fourth query: 
      
      
        
      X N  
      . E  
      . E  
      . E  
      
      
      
        
        
      
  
  For the fifth query: 
      
      
        
      ..XXX EENNN  
      ...X. EEENN  
      ...X. EEENN  
      ...X. EEENN  
      
  
  This query is simply the entire grid. It cannot be determined only from whether each cell is exitable because the below grid produces the above "exitability grid" as well: 
      
      
        
      ..XXX  
      ...XX  
      ...XX  
      ...XX  
      
solution: // Problem: C. Omkar and Determination
  // Contest: Codeforces - Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)
  // URL: https://codeforces.com/contest/1586/problem/C
  // Memory Limit: 256 MB
  // Time Limit: 2000 ms
  // 
  // Powered by CP Editor (https://cpeditor.org)
  
  import java.io.*;
  import java.util.*;
  
  import static java.lang.Math.max;
  import static java.lang.Math.min;
  import static java.lang.Math.abs;
  
  
  /**
   * zxz 
   * problem link:
   **/
  public class Main {
      //put some data here
  
      /**
       * do some clean action before next testcase
       */
      private void clear() {
  
      }
  
  
      private void solve() throws Exception {
          rf();
          int n = ri();
          int m = ri();
          boolean [][] mp = new boolean [n][m];
          for(int i = 0; i < n; i++){
          	rf();
          	char [] s = rs2c();
          	for(int j = 0; j < m; j++){
          		if(s[j] == 'X'){
          			mp[i][j] = true;
          		}
          	}
          }
          
          int [] sum = new int[m];
          int total = 0;
          for(int j = 0; j < m - 1; j++){
          	for(int i = 1; i < n; i++ ){
          		if(mp[i][j] && mp[i - 1][j + 1]){
          			total ++;
          		}
          	}
          	sum[j + 1] = total;
          	
          }
          rf();
          int q = ri();
          
          while(q -- > 0){
          	rf();
          	int a = ri(), b = ri();
          	if(sum[b - 1] - sum[a - 1] == 0){
          		addAns("yes");
          	}else{
          		addAns("no");
          	}
          } 
  
      }
  
      private void run() throws Exception {
  
  //        rf();
  //        int T = ri();
          int T = 1;
  
          while (T-- > 0) {
              solve();
              if (T != 0) {
                  clear();
              }
          }
          printAns();
      }
  
      public static void main(String[] args) throws Exception {
          new Main().run();
      }
  
      StringBuilder sb = new StringBuilder();
      BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st;
  
  	private void addAns(int a){
  		sb.append(a + "\n");
  	}
  	
  	private void addAns(long a){
  		sb.append(a + "\n");
  	}
  	
  	private void addAns(String s){
  		sb.append(s + "\n");
  	}
  
      private void rf() throws IOException {
          st = new StringTokenizer(infile.readLine());
      }
  
  
      private int ri() {
          return Integer.parseInt(st.nextToken());
      }
  
      private long rl() {
          return Long.parseLong(st.nextToken());
      }
  
  	private char [] rs2c(){
  		return st.nextToken().toCharArray();
  	}
  	
  	private String rs(){
  		return st.nextToken();
  	}
  
      private void printAns() {
          System.out.println(sb);
      }
  
      private int[] readArr(int N) throws Exception {
          int[] arr = new int[N];
          rf();
          for (int i = 0; i < N; i++) {
              arr[i] = Integer.parseInt(st.nextToken());
          }
          return arr;
      }
  
      private void print(int[] arr) {
          //for debugging only
          for (int x : arr) {
              System.out.print(x + " ");
          }
          System.out.println();
      }
      
      private void print(long[] arr) {
          //for debugging only
          for (long x : arr) {
              System.out.print(x + " ");
          }
          System.out.println();
      }
  
      private long[] readArr2(int N) throws Exception {
          long[] arr = new long[N];
          st = new StringTokenizer(infile.readLine());
          for (int i = 0; i < N; i++) {
              arr[i] = Long.parseLong(st.nextToken());
          }
          return arr;
      }
  
      private boolean isPrime(long n) {
          if (n < 2) {
              return false;
          }
          if (n == 2 || n == 3) {
              return true;
          }
          if (n % 2 == 0 || n % 3 == 0) {
              return false;
          }
          long sqrtN = (long) Math.sqrt(n) + 1;
          for (long i = 6L; i <= sqrtN; i += 6) {
              if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                  return false;
              }
          }
          return true;
      }
  
      private long gcd(long a, long b) {
          if (a > b) {
              a = (a + b) - (b = a);
          }
          if (a == 0L) {
              return b;
          }
          return gcd(b % a, a);
      }
      
      private int gcd(int a, int b) {
          if (a > b) {
              a = (a + b) - (b = a);
          }
          if (a == 0) {
              return b;
          }
          return gcd(b % a, a);
      }
      
      private double pow(double x, long N) {
          double ans = 1.0;
          // 贡献的初始值为 x
          double x_contribute = x;
          // 在对 N 进行二进制拆分的同时计算答案
          while (N > 0) {
              if (N % 2 == 1) {
                  // 如果 N 二进制表示的最低位为 1，那么需要计入贡献
                  ans *= x_contribute;
              }
              // 将贡献不断地平方
              x_contribute *= x_contribute;
              // 舍弃 N 二进制表示的最低位，这样我们每次只要判断最低位即可
              N /= 2;
          }
          return ans;
      }
      
      long pow_mod(long x, long i, long mod){
  	    if(i == 0){
  	        return 1;
  	    }
  	    long temp = pow_mod(x, i >> 1, mod);
  	    temp = temp * temp % mod;
  	    if((i & 1 )!= 0){
  	        temp = temp * x % mod;
  	    }
  	    return temp;
  	}
      
  
  }
  