#include <bits/stdc++.h>
using namespace std;
using lld = long long;
const int MOD = (int)1e9 + 7;
struct Int {
  Int(int v = 0) : v(v % MOD) {}
  Int(lld v) : v(v % MOD) {}
  int v;
  friend Int operator+(const Int& lhs, const Int& rhs) {
    return Int((lhs.v + rhs.v) % MOD);
  }
  friend Int operator-(const Int& lhs, const Int& rhs) {
    return Int((lhs.v - rhs.v + MOD) % MOD);
  }
  friend Int operator*(const Int& lhs, const Int& rhs) {
    return Int(((lld)lhs.v * rhs.v) % MOD);
  }
  friend Int operator/(const Int& lhs, const Int& rhs) {
    return Int(((lld)lhs.v * rhs.pow(MOD - 2)) % MOD);
  }
  int pow(int m) const {
    int ret = 1, v = this->v;
    for (; m; m >>= 1, v = (lld)v * v % MOD)
      if (m & 1) ret = (lld)ret * v % MOD;
    return ret;
  }
};
void solve() {
  int N, M, r, c, y, x;
  Int p;
  cin >> N >> M >> r >> c >> y >> x >> p.v;
  p = 1 - p / 100;
  int dr = -1, dc = -1, ir = r, ic = c;
  if (r + dr < 1 || r + dr > N) dr *= -1;
  if (c + dc < 1 || c + dc > M) dc *= -1;
  int idr = dr, idc = dc;
  Int a = 0, b = 1;
  for (;;) {
    r += dr;
    c += dc;
    a = a + 1;
    if (r == y || c == x) {
      a = a * p;
      b = b * p;
    }
    if (r + dr < 1 || r + dr > N) dr *= -1;
    if (c + dc < 1 || c + dc > M) dc *= -1;
    if (r == ir && c == ic && dr == idr && dc == idc) break;
  }
  cout << (a / (1 - b)).v << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  for (cin >> T; T--;) solve();
}

### Prompt

Please create a solution in CPP to the following problem:

The statement of this problem shares a lot with problem A. The differences are that in this problem, the probability is introduced, and the constraint is different.

A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).

In one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.

Each second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell. 

After a lot of testings in problem A, the robot is now broken. It cleans the floor as described above, but at each second the cleaning operation is performed with probability \frac p {100} only, and not performed with probability 1 - \frac p {100}. The cleaning or not cleaning outcomes are independent each second.

Given the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the expected time for the robot to do its job.

It can be shown that the answer can be expressed as an irreducible fraction \frac x y, where x and y are integers and y not ≡ 0 \pmod{10^9 + 7} . Output the integer equal to x ⋅ y^{-1} mod (10^9 + 7). In other words, output such an integer a that 0 ≤ a < 10^9 + 7 and a ⋅ y ≡ x \pmod {10^9 + 7}.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.

A test case consists of only one line, containing n, m, r_b, c_b, r_d, c_d, and p (4 ≤ n ⋅ m ≤ 10^5, n, m ≥ 2, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m, 1 ≤ p ≤ 99) — the sizes of the room, the initial position of the robot, the position of the dirt cell and the probability of cleaning in percentage.

Output

For each test case, print a single integer — the expected time for the robot to clean the dirty cell, modulo 10^9 + 7.

Example

Input


6
2 2 1 1 2 1 25
3 3 1 2 2 2 25
10 10 1 1 10 10 75
10 10 10 10 1 1 75
5 5 1 3 2 2 10
97 98 3 5 41 43 50


Output


3
3
15
15
332103349
99224487

Note

In the first test case, the robot has the opportunity to clean the dirty cell every second. Using the [geometric distribution](https://en.wikipedia.org/wiki/Geometric_distribution), we can find out that with the success rate of 25\%, the expected number of tries to clear the dirty cell is \frac 1 {0.25} = 4. But because the first moment the robot has the opportunity to clean the cell is before the robot starts moving, the answer is 3.

<image> Illustration for the first example. The blue arc is the robot. The red star is the target dirt cell. The purple square is the initial position of the robot. Each second the robot has an opportunity to clean a row and a column, denoted by yellow stripes.

In the second test case, the board size and the position are different, but the robot still has the opportunity to clean the dirty cell every second, and it has the same probability of cleaning. Therefore the answer is the same as in the first example.

<image> Illustration for the second example.

The third and the fourth case are almost the same. The only difference is that the position of the dirty cell and the robot are swapped. But the movements in both cases are identical, hence the same result.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using lld = long long;
const int MOD = (int)1e9 + 7;
struct Int {
  Int(int v = 0) : v(v % MOD) {}
  Int(lld v) : v(v % MOD) {}
  int v;
  friend Int operator+(const Int& lhs, const Int& rhs) {
    return Int((lhs.v + rhs.v) % MOD);
  }
  friend Int operator-(const Int& lhs, const Int& rhs) {
    return Int((lhs.v - rhs.v + MOD) % MOD);
  }
  friend Int operator*(const Int& lhs, const Int& rhs) {
    return Int(((lld)lhs.v * rhs.v) % MOD);
  }
  friend Int operator/(const Int& lhs, const Int& rhs) {
    return Int(((lld)lhs.v * rhs.pow(MOD - 2)) % MOD);
  }
  int pow(int m) const {
    int ret = 1, v = this->v;
    for (; m; m >>= 1, v = (lld)v * v % MOD)
      if (m & 1) ret = (lld)ret * v % MOD;
    return ret;
  }
};
void solve() {
  int N, M, r, c, y, x;
  Int p;
  cin >> N >> M >> r >> c >> y >> x >> p.v;
  p = 1 - p / 100;
  int dr = -1, dc = -1, ir = r, ic = c;
  if (r + dr < 1 || r + dr > N) dr *= -1;
  if (c + dc < 1 || c + dc > M) dc *= -1;
  int idr = dr, idc = dc;
  Int a = 0, b = 1;
  for (;;) {
    r += dr;
    c += dc;
    a = a + 1;
    if (r == y || c == x) {
      a = a * p;
      b = b * p;
    }
    if (r + dr < 1 || r + dr > N) dr *= -1;
    if (c + dc < 1 || c + dc > M) dc *= -1;
    if (r == ir && c == ic && dr == idr && dc == idc) break;
  }
  cout << (a / (1 - b)).v << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  for (cin >> T; T--;) solve();
}

```