#P11156. 【MX-X6-T2】もしも

【MX-X6-T2】もしも

Background

Original problem link: https://oier.team/problems/X6C


もしも\\ 数字がない世界だったら\\ 生きる期限なんて\\ なかったのかな\\ もしもの話なら良かった\\ また出逢えるからって\\ 言うんだ\\ またね。

—— もしも - Nanatsukaze / Dankidz

Can division help us erase the numbers in this world?

If not, can we meet again?

Problem Description

Suppose there is a positive integer sequence a1,a2,,ana_1, a_2, \ldots, a_n, where:

  • For i3i \ge 3, aia_i equals ai2ai1\dfrac{a_{i-2}}{a_{i-1}} rounded up;
  • For any 1in1 \le i \le n, 1ai1091 \le a_i \le 10^9.

Now given nn and ana_n, find any possible pair a1,a2a_1, a_2.

Rounding up a number xx means the smallest integer x\ge x. For example, 73\dfrac{7}{3} rounded up equals 33, and 44 rounded up equals 44.

Input Format

Each test point contains multiple sets of testdata. The first line contains an integer TT, the number of test cases.

Then follow TT lines. Each line contains two integers separated by a space, representing n,ann, a_n for that test case.

Output Format

For each test case, output one line with two integers, representing one possible pair a1,a2a_1, a_2. If there are multiple solutions, output any one. It can be proven that within the constraints of this problem, a solution always exists.

3
3 1
3 2
6 3
114 514
2005 1130
59001 897

Hint

Sample Explanation

For the three test cases, the sequences are:

  • a=[114,514,1]a=[114,514,1]
  • a=[2005,1130,2]a=[2005,1130,2]
  • a=[59001,897,66,14,5,3]a=[59001,897,66,14,5,3]

Constraints

For all testdata, 1T10001 \le T \le 1000, 3n1093 \le n \le 10^9, 1an1091 \le a_n \le 10^9.

There are 1010 groups of testdata in total:

  • For the first 22 groups, additionally n6n \le 6, an10a_n \le 10
  • For the first 55 groups, additionally n1000n \le 1000
  • For groups 66 and 77, additionally an=1a_n = 1

Translated by ChatGPT 5