#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e9+7;
ll binpow(ll x, int y = 1e9+5){
ll ans = 1;
x %= N;
while(y){
if(y & 1) ans = (ans * x)%N;
x = (x*x)%N;
y /= 2;
}
return ans;
}
void solve(){
ll n,m,a,b,x,y,pop; cin >> n >> m >> a >> b >> x >> y >> pop;
pop = 1ll-(pop*binpow(100))%N;
pop += N; pop%=N;
int i=-1,j=-1;
ll p = 0;
ll p2 = 1;
for(int q = 0; q < (n-1)*(m-1)*4; q++){
if(a+i > n || a+i < 1) i *= -1;
if(b+j > m || b+j < 1) j *= -1;
a += i; b += j;
p=(p+1)%N;
if(a == x || b == y){
p= (p*pop)%N;
p2 = (p2*pop)%N;
}
}
cout << (p*binpow(1-p2+N))%N << '\n';
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1; cin >> t;
while(t--) solve();
}
1405A - Permutation Forgery | 1733A - Consecutive Sum |
1733B - Rule of League | 1733C - Parity Shuffle Sorting |
1264A - Beautiful Regional Contest | 1695A - Subrectangle Guess |
467B - Fedor and New Game | 252C - Points on Line |
735C - Tennis Championship | 992A - Nastya and an Array |
554A - Kyoya and Photobooks | 79B - Colorful Field |
265B - Roadside Trees (Simplified Edition) | 1362C - Johnny and Another Rating Drop |
1214C - Bad Sequence | 1091B - New Year and the Treasure Geolocation |
244A - Dividing Orange | 1061C - Multiplicity |
1312A - Two Regular Polygons | 801A - Vicious Keyboard |
510B - Fox And Two Dots | 616D - Longest k-Good Segment |
1604A - Era | 555B - Case of Fugitive |
551A - GukiZ and Contest | 1399F - Yet Another Segments Subset |
1371C - A Cookie for You | 430B - Balls Game |
1263A - Sweet Problem | 1332B - Composite Coloring |