# Covid Spread solution codechef

## Covid Spread solution codechef

A disease is spreading through ChefLand!

The disease spreads as follows:

• At the end of day 00, a single person is infected with the disease.
• During the next 1010 days, the number of infected people doubles each day, until the disease has spread to all people in ChefLand.
• From day 1111 onwards, the number of infected people triples each day, until the disease has spread to all people in ChefLand.

You are given the population of ChefLand NN and a day DD. How many people in ChefLand are infected at the end of day DD?

### Input Format

• The first line of input contains a single integer TT, denoting the number of test cases. The description of TT test cases follows.
• Each test case consists of a single line containing two space-separated integers NN and DD — the population of ChefLand and the day for which you need to find the number of infected people, respectively.

### Output Format

• For each test case, print one line containing a single integer — the number of infected people in ChefLand at the end of day DD.

• 1T3001≤T≤300
• 1N1081≤N≤108
• 0D1080≤D≤108

### Subtasks

Subtask 1 (30 points): D20D≤20

Subtask 2 (70 points): Original constraints

### Sample Input 1

4
100 3
2000 10
6000 11
10 11


### Sample Output 1

8
1024
3072
10


### Explanation

Test Case 1:

• At the end of day 11, the number of infected people is 2×1=22×1=2.
• At the end of day 22, the number of infected people is 2×2=42×2=4.
• At the end of day 33, the number of infected people is 2×4=82×4=8.

Test Case 2: Following the rules in the statement, it can be seen that at the end of day 1010, the total number of infected people is 10241024.

Test Case 3: Note that starting at day 1111, the number of infected people triples each day, 3×1024=30723×1024=3072.

Test Case 4: At the end of day 33, the number of infected people is 88. Since there are only 1010 people in ChefLand (which is less than 2×8=162×8=16), at the end of day 44 all people in ChefLand are infected and thus the number of infected people is 1010 for all days from day 44 onwards, including day 1111.