Chef wants to make a feast. In order to do that, he needs a lot of different ingredients. Each ingredient has a certain tastiness; the tastiness of each ingredient may be any positive integer. Initially, for each tastiness between $K$ and $K+N-1$ (inclusive), Chef has an infinite supply of ingredients with this tastiness.
The ingredients have a special property: any two of them can be mixed to create a new ingredient. If the original ingredients had tastiness $x$ and $y$ (possibly $x = y$), the new ingredient has tastiness $x+y$. The ingredients created this way may be used to mix other ingredients as well. Chef is free to mix ingredients in any way he chooses any number of times.
Let's call a tastiness $v$ ($v > 0$) unreachable if there is no way to obtain an ingredient with tastiness $v$; otherwise, tastiness $v$ is reachable. Chef wants to make ingredients with all reachable values of tastiness and he would like to know the number of unreachable values. Help him solve this problem. Since the answer may be large, compute it modulo $1,000,000,007$ ($10^9+7$).
Note that there is an infinite number of reachable values of tastiness, but it can be proven that the number of unreachable values is always finite for $N \ge 2$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains two space-separated integers $N$ and $K$.

-----Output-----
For each test case, print a single line containing one integer — the number of unreachable values of tastiness, modulo $1,000,000,007$.

-----Constraints-----
- $1 \le T \le 10^5$
- $2 \le N \le 10^{18}$
- $1 \le K \le 10^{18}$

-----Subtasks-----
Subtask #1 (20 points): $N = 2$
Subtask #2 (80 points): original constraints

-----Example Input-----
2
2 1
3 3

-----Example Output-----
0
2

-----Explanation-----
Example case 1: It is possible to obtain ingredients with all values of tastiness.
Example case 2: Ingredients with tastiness $1$ and $2$ cannot be made.

```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 = '# t=int(input())\n# for _ in range(t):\n#     n,k=map(int,input().split())\n#     summation=0\n#     last_term=k-1\n#     common_difference=n-1\n#     first_term=last_term%common_difference\n#     if first_term==0:\n#         first_term=common_difference\n#     no_of_terms=(last_term-first_term)//common_difference + 1\n#     #print(no_of_terms,first_term,last_term,common_difference)\n#     summation=(((no_of_terms)*(first_term+last_term))//2)%1000000007\n#     print(summation)\n#\n# import math\n#\n# MOD = 1000000007\n# t = int(input())\n# for _ in range(t):\n#     n, k = map(int, input().split())\n#     first = k - 1;\n#     diff = n - 1;\n#     t = (first + diff) // (diff)\n#     # print(t)\n#     y = (2 * (first) - (t - 1) * (diff))\n#     if (y % 2 == 0):\n#         y = y // 2;\n#     else:\n#         t = t // 2;\n#\n#     ans = y * t;\n#     ans = ans % MOD\n#     # print("n,k:"+str(n)+" "+str(k))\n#     print(ans)\nMOD = 1000000007\nfor _ in range(int(input())):\n n,k = map(int,input().split())\n if n==2:\n  last_term = k-1\n  first_term = 1\n  no_terms = last_term\n  ans = (last_term*(last_term+1))//2\n  print(ans%MOD)\n  \n else:\n  print(1)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 12975