Codeforces•Jun 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 2⋅x+k⋅y=n2⋅x+k⋅y=n.

Input

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

The only line of each test case contains two integers nn and kk (1≤k≤n≤10181≤k≤n≤1018; k≠2k≠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 (YES, yes, Yes will all be recognized as positive answer, NO, no 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