Limits 1s, 512 MB

You are given an n×mn \times m grid. You can go from point (x1,y1)(x_1, y_1) to any point (x2,y2)(x_2, y_2) of grid if and only if x1x_1 is not equal to x2x_2 and y1y_1 is not equal to y2y_2 and their Euclidian distance is an integer value. You have to tell whether you can go from the top left point (1,1)(1, 1) to the bottom right point (n,m)(n, m) using any number of valid moves.


The first line of input contains a single integer TT(1T1000)(1 \le T \le 1000), the number of test cases..

For each test case, there are two integers nn(1n106)(1 \le n \le 10^{6}) and mm(1m106)(1 \le m \le 10^{6}).


For each test case, print “Case X: S”, where “X” is the case number. “S” will be “YES” if it is possible to go from the top left cell (11,11) to the bottom right cell (nn,mm), and “NO” otherwise.


1 1
2 2
Case 1: YES
Case 2: NO

Euclidean distance between two points coordinates (x1x_1,y1y_1) and (x2x_2,y2y_2) is given by

dist((x1,y1),(x2,y2))=(x1x2)2+(y1y2)2\text{dist}\left(\left(x_1, y_1\right), \left(x_2, y_2\right)\right) = \sqrt{\left(x_1 - x_2\right)^2 + \left(y_1 - y_2\right)^2}


Login to submit.


47% Solution Ratio
Lazy_ProgrammerEarliest, Jan '23
Samee_SevasFastest, 0.0s
Kuddus.6068Lightest, 4.9 MB
Fellow_juniorShortest, 370B
Toph uses cookies. By continuing you agree to our Cookie Policy.