They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.

Limak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Rows are numbered 1 through h from top to bottom. Columns are numbered 1 through w from left to right.

Also, Limak has a single domino. He wants to put it somewhere in a grid. A domino will occupy exactly two adjacent cells, located either in one row or in one column. Both adjacent cells must be empty and must be inside a grid.

Limak needs more fun and thus he is going to consider some queries. In each query he chooses some rectangle and wonders, how many way are there to put a single domino inside of the chosen rectangle?

Input

The first line of the input contains two integers h and w (1 ≤ h, w ≤ 500) – the number of rows and the number of columns, respectively.

The next h lines describe a grid. Each line contains a string of the length w. Each character is either '.' or '#' — denoting an empty or forbidden cell, respectively.

The next line contains a single integer q (1 ≤ q ≤ 100 000) — the number of queries.

Each of the next q lines contains four integers r1i, c1i, r2i, c2i (1 ≤ r1i ≤ r2i ≤ h, 1 ≤ c1i ≤ c2i ≤ w) — the i-th query. Numbers r1i and c1i denote the row and the column (respectively) of the upper left cell of the rectangle. Numbers r2i and c2i denote the row and the column (respectively) of the bottom right cell of the rectangle.

Output

Print q integers, i-th should be equal to the number of ways to put a single domino inside the i-th rectangle.

Examples

Input

5 8
....#..#
.#......
##.#....
##..#.##
........
4
1 1 2 3
4 1 4 1
1 2 4 5
2 5 5 8


Output

4
0
10
15


Input

7 39
.......................................
.###..###..#..###.....###..###..#..###.
...#..#.#..#..#.........#..#.#..#..#...
.###..#.#..#..###.....###..#.#..#..###.
.#....#.#..#....#.....#....#.#..#..#.#.
.###..###..#..###.....###..###..#..###.
.......................................
6
1 1 3 20
2 10 6 30
2 10 7 30
2 2 7 7
1 7 7 7
1 8 7 8


Output

53
89
120
23
0
2

Note

A red frame below corresponds to the first query of the first sample. A domino can be placed in 4 possible ways.

<image>
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Contest {
	//static ArrayList<Integer> prime=new ArrayList();
	
	   public static TreeMap<Long,Integer> t1=new TreeMap();
	   public static void solve()
	    {
	      long m=1;
	      for(int j=2;j<=1000;j++)
	      {
	         
	          if(isprime(j))
	          {
	              m=m*j;
	              if(m>1000000)
	              {
	                  break;
	              }else{
	                  t1.put(m,1);
	              }
	          }
	      }
	    }
	
    public static int gcd(int n1, int n2)
    {
        if (n2 != 0)
            return gcd(n2, n1 % n2);
        else
            return n1;
    }
	
//////////////////	
	public static class trie {
        int x,y,z;
        trie (int x,int y,int z){
            this.x=x;
            this.y=y;
            this.z=z;
        }
	
	} 
        
	public static class pair {
        int x,y;
        pair (int x,int y){
            this.x=x;
            this.y=y;
        }
        public boolean equals(Object o) {
        	if(o instanceof pair) {
        		pair p = (pair)o;
        		return (x == p.x && y == p.y);
        	}
        	return false;
        }
        public int hashCode() {
        	return (Integer.hashCode(x) * 3 + Integer.hashCode(y) );
        }
    }
	
//////////////////	
	
	static class Cmp implements Comparator<pair>
	{
		public int compare(pair a,pair b)
		{
			if(a.x==b.x)
			{
				return(a.y-b.y);
			}
			return(a.x-b.x);
		}
	}
	
	
//////////////////
	
	
	
	
//////////////////
	
	
	
	
	
	   static class FastReader
	   {
		   BufferedReader br;
		   StringTokenizer st;
		   public FastReader()
		   {
			   br = new BufferedReader(new InputStreamReader(System.in));
		   }
		   
		   
		   String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
		   
		   
		   int nextInt()
		   {
			   return Integer.parseInt(next());
		   }
		   long nextLong()
		   {
			   return Long.parseLong(next());
		   }
		   double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
		   
		   String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	   }
	   
////////////////////// 
	//public static ArrayList<Integer> a=new ArrayList();
	   
	  public static ArrayList<Integer> Divisors(int n) 
	   { 
	       // Note that this loop runs till square root 
		  ArrayList<Integer> a=new ArrayList();
		   long sum=0;
	       for (int i=1; i*i<=(n); i++) 
	       { 
	           if (n%i == 0) 
	           { 
	               // If divisors are equal, print only one 
	               if (n/i == i) 
	               {
	                  // printf("%d ", i); 
	            	   sum=sum+1;
	            	   a.add(i);
	               }
	     
	               else // Otherwise print both 
	               {
	                   //printf("%d %d ", i, n/i); 
	            	   sum=sum+2;
	            	   a.add(i);
	            	   a.add(n/i);
	               }
	           } 
	       } 
	       return(a);
	   } 
	   
/////////////////////	  
	  
	  public static long SmallestPrimeDivisor(long n) 
	  { 
	      // if divisible by 2 
	      if (n % 2 == 0) 
	          return 2; 
	    
	      // iterate from 3 to sqrt(n) 
	      for (long i = 3; i * i <= n; i += 2) { 
	          if (n % i == 0) 
	              return i; 
	      } 
	    
	      return n; 
	  } 
	    
////////////////////	  
	   
	   public static boolean isprime(long n)
	    {
	        int count=0;
	     
	        for(long i=2;i*i<=n;i++)
	        {
	            if(n%i==0)
	            {
	                return(false);
	            }
	        }
	        return(true);
	    }
	
	   
//////////////////////
	   
	     //   (x^n)%1000000007
	   public static long modularExponentiation(long x,long n,long M)
	   {
	       if(n==0)
	           return 1;
	       else if(n%2 == 0)        //n is even
	           return modularExponentiation((x*x)%M,n/2,M);
	       else                             //n is odd
	           return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

	   }
	   
	   public static long nCr(int n,int k)
	   {
		  if(k==0)
			  return 1;
		  return(n*nCr(n-1,k-1)/k);
	   }
	   public static long factorial(int n)
	   {
		   if(n==1)
			   return 1;
		   return((n)*factorial(n-1));
	   }
	   
	   public static void debug(Object...o) {
		    System.out.println( Arrays.deepToString(o) );
	   }
	   
	   public static boolean prime[]=new boolean[100005];
	   //prime[j]==false means it's a prime.
	   public static void seive()
	   {
		   prime[0]=false;
		   prime[1]=false;
		   for(int i=2;i*i<=100005;i++)
		   {
			   if(!prime[i])
			   {
				   for(int j=i*i;i<=100005;j+=i)
				   {
					   prime[j]=true;
				   }
			   }
		   }
	   }
	 
	 
	    public static boolean equals(StringBuilder sb1, StringBuilder sb2){
	    
	        if(sb1 == sb2)
	  
	        if(sb1 == null || sb2 == null)
	            return false;
	        
	        boolean isEqual = true;
	  
	        if(sb1.length() == sb2.length()){
	  
	            for(int i = 0 ; i < sb1.length(); i++){
	                
	                if(sb1.charAt(i) != sb2.charAt(i)){
	                    isEqual = false;
	                    break;
	                }
	            }
	            
	        }else{
	            isEqual = false;
	        }
	        
	        return isEqual;
	    }
	   
	    
	    public static boolean IsPalindrome(String s,int n)
	    {
	    	
	    	for(int i=0;i<n/2;i++)
	    	{
	    		if(s.charAt(i)!=s.charAt(n-i-1))
	    		{
	    			return false;
	    		}
	    	}
	    	return true;
	    }
	   
	   
	   
	   
	    
		public static void main(String []args) throws Exception
		{
			
			
			 FastReader in =new FastReader();	
			 PrintWriter pw = new PrintWriter(System.out);
		    //Scanner sc=new Scanner(System.in)
		    
			
			int n=in.nextInt();
			int m=in.nextInt();
			char c[][]=new char[n][m];
			int ans[][]=new int[n+1][m+1];
			int a1[][]=new int[n][m];
			int b1[][]=new int[n][m];
			for(int i=0;i<n;i++)
			{
				c[i]=in.nextLine().toCharArray();
			}
			ans[1][1]=0;
			for(int j=1;j<m;j++)
			{
				if(c[0][j]=='.' && c[0][j-1]=='.')
				{
					ans[1][j+1]=ans[1][j]+1;
				}
				else
				{
					ans[1][j+1]=ans[1][j];
				}
			}
		
			for(int i=1;i<n;i++)
			{
				if(c[i][0]=='.' && c[i-1][0]=='.')
				{
					ans[i+1][1]=ans[i][1]+1;
				}
				else
				{
					ans[i+1][1]=ans[i][1];
				}
			}
			
			for(int i=1;i<n;i++)
			{
				for(int j=1;j<m;j++)
				{
					
				
					
										
					ans[i+1][j+1]=ans[i][j+1]+ans[i+1][j] - ans[i][j];
					if(c[i][j]=='.' && c[i-1][j]=='.')
					{
						ans[i+1][j+1]++;
					}
					if(c[i][j]=='.' && c[i][j-1]=='.')
					{
						ans[i+1][j+1]++;
					}
				}
			}
			 
			for(int j=1;j<m;j++)
			{
				for(int i=0;i<n;i++)
				{
					if(c[i][j]=='.' && c[i][j-1]=='.')
					{
						if(i>0)
						{
					    a1[i][j]=a1[i-1][j]+1;
						}
						else
						{
							a1[i][j]=1;
						}
					}
					else
					{
						if(i>0)
						{
						a1[i][j]=a1[i-1][j];
						}
						else
						{
							a1[i][j]=0;
						}
					}
				}
			}
			
			
			for(int i=1;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					
					if(c[i][j]=='.' && c[i-1][j]=='.')
					{
					   if(j>0)
					   {
					   b1[i][j]=b1[i][j-1]+1;	
					   }
					   else
					   {
						   b1[i][j]=1;
					   }
					}
					else
					{
						if(j>0)
						{
						b1[i][j]=b1[i][j-1];
						}
						else
						{
							b1[i][j]=0;
						}
					}
				}
			}
			
			/*
			for(int i=0;i<=n;i++)
			{
				for(int j=0;j<=m;j++)
				{
					pw.print(ans[i][j]+" ");
				}
				pw.println("");
			}
			pw.println("");
			pw.println("");
			
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					pw.print(a1[i][j]+" ");
				}
				pw.println("");
			}
			pw.println("");
			pw.println("");
			
			
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					pw.print(b1[i][j]+" ");
				}
				pw.println("");
			}
			pw.println("");
			pw.println("");
			*/
			
			int q=in.nextInt();
			while(q-->0)
			{
				int x1=in.nextInt();
				int y1=in.nextInt();
				int x2=in.nextInt();
				int y2=in.nextInt();
				
				long p = ans[x2][y2] +ans[x1-1][y1-1] - ans[x1-1][y2] - ans[x2][y1-1];
				if(y1>=2)
				{
					if(x1>=2)
					{
					  p=p- ( a1[x2-1][y1-1] - a1[x1-2][y1-1] );
					}
					else
					{
						p = p -  a1[x2-1][y1-1];
					}
				}
				if(x1>=2)
				{
					if(y1>=2)
					{
					p = p - ( b1[x1-1][y2-1] - b1[x1-1][y1-2]  );
					}
					else
					{
						p= p- b1[x1-1][y2-1];
					}
				}
				pw.println(p);

			}
			
			
		   	 pw.flush();
			 pw.close();
		   			
		}
			
	}	
		
		
		
		
		
		
		
		
		
		
	

