Im9223372036854775808's blog

By Im9223372036854775808, history, 5 months ago, In English

Description

Nothing to say, just solve it...

**Note: ** ω means omega — The first transfinite ordinal, the smallest ordinal greater than all the positive integers.

Middle-growing hierarchy has following rules:

m ( 0 , n ) = n + 1

m ( α + 1 , n ) = m ( α , m ( α , n ) )

m ( α , n ) = m ( α [ n ] , n )

Although it is not clarified in the original definition, ω denotes a countable ordinal equipped with a fixed system of fundamental sequences of limit ordinals up to ω , and n denotes a natural number.

Input

The first line contains the number of test cases t (1<=t<=500) The description of the test cases follows.

The only line of each test case contains two integers α , n (1<=n<=100), (1<= α <=100)

α also denotes as ω (i can be used as w)

Output

For each test case, output answer

Examples

Example 1

Input

5

1 1

2 2

7 2

w 3

0 0

Output

3

6

130

11

1

Source: MGH

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

κ 0 ( n ) = ∑ i = 1 a f l i m ( B M S ) ( n { 990 } 2 )

»
5 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I believe you need to specify a specific "sequence of limit ordinals" in order for this to be concretely defined. Anyway, it looks like the finite case is m(x,y)=2^x+y so essentially just requires bigint to implement that.