Kajaria has an empty bag and 2 types of tiles - 
tiles of type $1$ have the number $X$ written and those of type $2$ have the number $Y$ written on them. He has an infinite supply of both type of tiles.
In one move, Kajaria adds exactly $1$ tile to the bag. He adds a tile of type $1$ with probability $p$ and a tile of type $2$ with probability $(1 - p)$.
If $2$ tiles in the bag have the same number written on them (say $Z$), they are merged into a single tile of twice that number ($2Z$).
Find the expected number of moves to reach the first tile with number $S$ written on it.
Notes on merging: 
- Consider that the bag contains tiles $(5, 10, 20, 40)$ and if the new tile added is $5$, then it would merge with the existing $5$ and the bag would now contain $(10, 10, 20, 40)$. The tiles $10$ (already present) and $10$ (newly formed) would then merge in the same move to form $(20, 20, 40)$, and that will form $(40, 40)$, which will form $(80)$.
Kajaria guarantees that:
- $X$ and $Y$ are not divisible by each other.
- A tile with number $S$ can be formed.

-----Input-----
- First line contains a single integer $T$ - the total no. of testcases
- Each testcase is described by $2$ lines:
- $X, Y, S$ - $3$ space-separated natural numbers
- $u, v$ - $2$ space-separated natural numbers describing the probability $p$
The value of $p$ is provided as a fraction in its lowest form $u/v$ ($u$ and $v$ are co-prime)

-----Output-----
- For each testcase, if the expected number of moves can be expressed as a fraction $p/q$ in its lowest form, print $(p * q^{-1})$ modulo $10^9 + 7$, where $q^{-1}$ denotes the modular inverse of $q$ wrt $10^9 + 7$.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $2 \leq X, Y \leq 5 * 10^{17}$
- $1 \leq S \leq 10^{18}$
- $1 \leq u < v \leq 10^{9}$

-----Sample Input-----
1
5 3 96
1 3

-----Sample Output-----
48

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# cook your dish here\nt=int(input())\nMOD=1000000007\ndef mod(n, m=MOD):\n n%=m\n while n<0: n+=m\n return n\n\ndef power(n, p):\n res=1\n while p:\n  if p%2: res=mod(res*n)\n  p//=2\n  n=mod(n*n)\n return res\n\nwhile t:\n ma=input().split()\n x=int(ma[0])\n y=int(ma[1])\n s=int(ma[2])\n ma=input().split()\n u=int(ma[0])\n v=int(ma[1])\n if s%x==0 and ((s // x) & ((s // x) - 1) == 0):\n  inv=power(u, MOD-2)\n  print(mod(mod(mod(s//x)*v)*inv))\n else:\n  inv=power(v-u, MOD-2)\n  print(mod(mod(mod(s//y)*v)*inv))\n t-=1\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13431