Romualdych and remainders
시간 제한2초메모리 제한1024 MB
각 질의 [a,b]와 나머지 r에 대해, x mod y = r을 만족하는 가장 작은 x와 적당한 y를 1 이상 2×10^18 이하에서 찾고, 불가능하면 -1 -1을 출력한다.
문제
Old man Romualdych learned about division with remainders and it just threw him off the hinges. The thing got him all mixed up and sweating like a pig. What a sad sight he was, hoping to find some number in the interval , that would produce the specified remainder when divided by some number . Let's face it --- Romualdych is not the sharpest tool in the shed, and even if he sinks his few remaining teeth into the task, he is not likely to cope without your help.
입력
The first line contains a single integer --- the number of tests in the file ().
Each of the following lines contains three integers: , --- interval bounds, and --- required remainder (, ).
출력
Print answers in the same order as the tests in the input file are given, one answer per line.
Each answer consists of two integers and , such that , , and the remainder from the division of by equals . If there are several possible answers that fit all the requirements, choose any answer with the minimal . If there are no possible answers, print two integers: and .
힌트
In the first test, 6 is divided by 3, and the remainder is indeed 0. Since 6 is the smallest number in the interval , this is the correct answer. Instead, the following answer can be printed too: and (minimizing is not required), while the answer and cannot be printed, because its is not minimal.
In the second test, there are no answers, since it is impossible to get a remainder of 10 for in the interval [3,5] regardless of the it is divided by.