Street Walk
Difficulty: Hard

Ram needs to cross the jungle, But in the jungle many paths are dangerous and cannot be taken. Consider the jungle as a n*n grid where, where grid positions are marked as '.' if it is safe else 'x'.Ram starts at the origin of the grid i.e. 0,0 and wants to reach the end of the grid i.e. n-1,n-1.He can only move down or right.

Count the total number of ways in which he can reach put of the jungle safely.

Since the answer can be large output ways mod 1000000007.

If there is no way output -1.

Note : Initial and Final position do not contain rock.

**Constraints :**

t<=10

n<=1000

**Input:**

First Line contain **t** the number of test cases.

Each test case consists of multiply lines.

First line of each test case consist of a single integer **n**, the size of the jungle.

n lines follow each consisting of **n characters**.

Each character can be either **'x'** or **'.'**

'x' denotes danger.

'.' denotes path.

**Output:**

Output **t** lines each consisting of the **number of ways mod 1000000007** to reach out of the jungle.

If there is no way to reach out of the jungle output **-1**. 


**Sample Input**

	2
	2
    ..
    ..
    3
    ..x
    ..x
    .x.

**Sample Output**

    2
    -1
    
    
    
**To be eligible for prizes you have to register for Code-O-Mania at the Zeitgeist site. To register visit [Zeitgeist][1]. Only those candidates who have registered on the [Zeitgeist website][2] for the Code-O-Mania contest will be eligible to avail the Prizes.**


  [1]: http://www.zeitgeist.org.in/#/
  [2]: http://zeitgeist.org.in/

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):

	#include<iostream>
    using namespace std;
    int mod=1000000007;
    int main()
    {
        static int t,i,j,way[1001][1001],n;
        char c[1001][1001];
        cin>>t;
        while (t--)
        {
            cin>>n;
            for (i=0;i<n;i++)
            {
                cin>>c[i];
            }
            way[0][0]=1;
            for (i=1;i<n;i++)
            {
                if (c[0][i]!='x')
                {
                    way[0][i]=way[0][i-1];
                }
                else
                {
                    way[0][i]=0;
                }
            }
            for (i=1;i<n;i++)
            {
                if (c[i][0]!='x')
                {
                    way[i][0]=way[i-1][0];
                }
                else
                {
                    way[i][0]=0;
                }
            }
            for (i=1;i<n;i++)
            {
                for (j=1;j<n;j++)
                {
                    if (c[i][j]!='x')
                    {
                        way[i][j]=way[i-1][j]+way[i][j-1];
                        way[i][j]%=mod;
                    }
                    else
                    {
                        way[i][j]=0;
                    }

                }
            }
            if (way[n-1][n-1])
                cout<<way[n-1][n-1]<<endl;
            else
                cout<<-1<<endl;
        }
        return 0;
    }