Kabir Singh is playing a game on the non-negative side of  x-axis. It takes him $1 second$ to reach from Pth position to (P−1)th position or (P+1)th position. 
Kabir never goes to the negative side and also doesn't stop at any moment of time.
The movement can be defined as  : 
- At the beginning he is at $x=0$ , at time $0$
- During the first round, he moves towards $x=1$ and comes back to the $x=0$ position.
- In the second round, he moves towards the $x=2$ and comes back again to $x=0$.
- So , at $Kth$ round , he moves to $x=K$ and comes back to $x=0$
So in this way game goes ahead.
For Example, the path of Kabir for $3rd$ round is given below.
$0−1−2−3−2−1−0$
The overall path followed by Kabir would look somewhat like this:
$0−1−0−1−2−1−0−1−2−3−2−1−0−1−2−3−4−3−…$
Now the task is , You are given Two Non-Negative integers $N$ , $K$ .
You have to tell the time at which Kabir arrives at $x=N$ for the $Kth$ time.
Note - Kabir visits all the points , he can not skip or jump over one point.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, two integers $N, K$. 

-----Output:-----
For each testcase, output in a single line answer i.e Time Taken by Kabir Singh modulo 1000000007.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $0 \leq N \leq 10^9$
- $1 \leq K \leq 10^9$

-----Sample Input:-----
4

0 1
1 1
1 3
4 6

-----Sample Output:-----
0
1
5
46

-----EXPLANATION:-----
Test Case 1:
Kabir starts the journey from the $N=0$ at time $t=0$ and it's the first time$ (K=1)$, he is here. So, the answer is $0$.
Test Case 3:
The path followed by Kabir to reach 1 for the third time is given below.
$0−1−0−1−2−1$
He reaches $1$ for the third time at $ t=5$.

```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 = "import sys\nfrom random import choice,randint\ninp=sys.stdin.readline\nout=sys.stdout.write\nflsh=sys.stdout.flush\n \nsys.setrecursionlimit(10**9)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n \ndef MI(): return map(int, inp().strip().split())\ndef LI(): return list(map(int, inp().strip().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]\ndef LI_(): return [int(x)-1 for x in inp().strip().split()]\ndef LF(): return [float(x) for x in inp().strip().split()]\ndef LS(): return inp().strip().split()\ndef I(): return int(inp().strip())\ndef F(): return float(inp().strip())\ndef S(): return inp().strip()\ndef pf(s): return out(s+'\\n')\ndef JA(a, sep): return sep.join(map(str, a))\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\n\ndef main():\n    from math import ceil\n    t = I()\n    l = []\n    for _ in range(t):\n        n,k=MI()\n        if n==0:\n            k-=1\n            ans = ((k)*((k+1)))%mod\n            l.append(ans)\n        else:\n            # if k==1:\n            #     ans = ((((n)*((n-1)))%mod)+ n%mod)%mod\n            #     l.append(ans)\n            # else:\n            #     k-=1\n            #     lr = (n%mod+((ceil(k/2)%mod))%mod\n            #     ans = ((lr*((lr-1))%mod\n            #     if k%2!=0:\n            #         ans= (ans%mod + n%mod)%mod\n            #     else:\n            #         ans = ((ans%mod)+((lr+n)%mod))%mod\n            #     l.append(ans)\n            if k%2!=0:\n                lr = k//2\n                l.append(((n*n)%mod+(lr*((2*n)%mod))%mod+(lr*(lr+1))%mod)%mod)\n            else:\n                lr = k//2\n                l.append(((n*n)%mod + (lr*(2*n)%mod)%mod + (lr*(lr-1))%mod)%mod)\n\n    for i in range(t):\n        pf(str(l[i]))\n\ndef __starting_point():\n    main()\n__starting_point()"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16911