Double Check

0

0 votes
Easy
Problem

A computer program named Eunoia is successful if it is able to place two checkers in a N x M grid-board(a rectangular board that has N x M cells) such that both the below conditions are satisfied :

  1.   the row number of the checkers are not equal.
  2.   the column number of the checkers are not equal.

Else, the program has failed.

Find the success probability of Eunoia if it randomly places the checkers on the board.

Note: Both the checkers cannot be placed in the same cell.

Input Format: -

First line contains T – no of testcases. Next T lines has two spaced integers N and M.

Output Format: -

Print T lines, the ith line corresponds to the answer of ith test case where two spaced integers P and Q are output denoting the success probability, P/Q where P and Q are co-prime.

if the probability is 0, output "0 1" in-place of P and Q.

Constraints:

1 <= T <= 100

1 <= N , M<= 109

N M >= 3

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?