CodeforcesJun 13, 2025

Coins

Hazrat Ali

Codeforces

Your task is to determine whether it is possible to represent nn burles in coins, i. e. whether there exist non-negative integers xx and yy such that 2x+ky=n2⋅x+k⋅y=n.

Input

The first line contains a single integer tt (1t1041≤t≤104) — the number of test cases.

The only line of each test case contains two integers nn and kk (1kn10181≤k≤n≤1018k2k≠2).

Output

For each test case, print YES if it is possible to represent nn burles in coins; otherwise, print NO. You may print each letter in any case (YESyesYes will all be recognized as positive answer, NOno and nO will all be recognized as negative answer).

Example
Input
4
5 3
6 1
7 4
8 8

Output
YES
YES
NO
YES


Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, s;
  cin >> n >> s;
  long long ans = s / n;
  if (s % n > 0) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}




Comments