Consider the infinite x$x$ axis. There are N$N$ impacts on this X-axis at integral points (X1$X_1$,X2$X_2$,....XN$X_N$)  (all distinct) . An impact at a point X$X$i propagates such that at a point X$X$0, the effect of the impact is K|Xi−X0|$K^{|X_i - X_0|}$. Given the point X0$X_0$, N$N$ and K$K$. Assume the total impact on X0$X_0$ is M$M$, find if it is possible to do so.Note: You are not required to find the set X

Formally print "yes" if this is possible and "no" if not possible.

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

-----Output:-----
-  The output of each test case is either "yes" or "no"

-----Constraints -----
-  1≤T≤1000$1\leq T \leq 1000$
-  1≤N≤100$1\leq N \leq 100$
-  1≤K≤1000$1\leq K \leq 1000$
-  1≤M≤1018$1\leq M \leq 10^{18}$
-  −109≤X0≤109$-10^9 \leq X_0 \leq 10^9$ 

-----Sample Input:-----
	2

4 3 10 10

2 3 10 10

-----Sample Output:-----
	no

yes

```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 = 'from math import log\r\nfor i in range (int(input())):\r\n    a = input().split(" ")\r\n    n,k,x,m = map(int,a)\r\n    ans = "no"\r\n    u = 0\r\n\r\n    if k != 2 and k != 1:\r\n        if x%k == 0:\r\n            x //= k\r\n            u = -1\r\n        elif x%k == 1:\r\n            n -= 1\r\n            x //= k\r\n            u = -1\r\n\r\n        if u == -1:     \r\n            while x != 0:\r\n                if x%k == 0:\r\n                    x //= k\r\n                elif x%k == 1:\r\n                    x //= k\r\n                    n -= 1\r\n                elif x%k == 2:\r\n                    x //= k\r\n                    n -= 2\r\n                else:\r\n                    break\r\n\r\n        if n == 0 and x == 0:\r\n            ans = "yes"\r\n\r\n    elif k == 1:\r\n        if x == n:\r\n            ans = "yes"\r\n\r\n    else:\r\n        lst = []\r\n        p = 0\r\n        N = n\r\n        while x != 0:\r\n            if x%2 == 0:\r\n                x //= 2\r\n                p += 1\r\n            elif x%2 == 1:\r\n                x //= 2\r\n                n -= 1\r\n                p += 1\r\n                lst.append(2**(p-1))\r\n\r\n        if len(lst) == N:\r\n            ans = "yes"\r\n            \r\n        if len(lst) < N:\r\n            k = 0\r\n            g = len(lst)\r\n            if lst[0] > 2:\r\n                g += int(log(lst[0])//log(2))-1\r\n                k = 1\r\n            for i in range(1,len(lst)):\r\n                if k == 1:\r\n                    g += int(log(lst[i]//lst[i-1],2))\r\n                elif lst[i] > 2*lst[i-1]:\r\n                    g += int(log(lst[i]//lst[i-1],2))-1\r\n                    k = 1\r\n                else:\r\n                    k = 0\r\n            if g >= N:\r\n                ans = "yes"\r\n\r\n    print(ans)\r\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13969