/* -*- coding: utf-8 -*- * * 2493.cc: No.2493 K-th in L2 with L1 - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_D = 100; /* typedef */ typedef tuple trpl; /* global variables */ trpl ps[MAX_D * 4]; /* subroutines */ /* main */ int main() { int qn; scanf("%d", &qn); while (qn--) { int di, ki; scanf("%d%d", &di, &ki), ki--; int n = 0; if (di == 0) ps[n++] = {0, 0, 0}; else { for (int y = -di; y <= di; y++) { int x0 = di - abs(y), x1 = -x0; int d2 = x0 * x0 + y * y; ps[n++] = {d2, x0, y}; if (x1 != x0) ps[n++] = {d2, x1, y}; } sort(ps, ps + n); } if (ki < n) printf("Yes\n%d %d\n", get<1>(ps[ki]), get<2>(ps[ki])); else puts("No"); } return 0; }