Fibonacci numbers grow fast. Taekhee wrote them on paper all the way to the millionth term and still was not satisfied, so he defined a sequence of his own that grows much faster.
The first term is a1=k. With Nn={1,2,3,…,n}, the next term is given by
an+1=∑∅=S⊆Nn∑i∈Sai
In other words, for every way of choosing at least one term among a1 through an, take the sum of the chosen terms, and an+1 is the total of all those sums.
For a1=1 the first few terms are
- a2=(a1)=1
- a3=(a1)+(a2)+(a1+a2)=4
- a4=(a1)+(a2)+(a3)+(a1+a2)+(a1+a3)+(a2+a3)+(a1+a2+a3)=24
Taekhee prepared Q questions about this sequence. Each question comes with its own first term a1, so each question is about its own sequence. Write a program that answers all of them.