Consider the trinomial (x2+x+1)n. We study the coefficients ci that appear when this expression is expanded:
c0+c1x+c2x2+⋯+c2nx2n
For example, (x2+x+1)3=1+3x+6x2+7x3+6x4+3x5+x6.
Write a program that:
The first line contains one integer k, the number of data sets, where 1≤k≤10000.
It is followed by k data sets, one per line. Each set consists of two non-negative integers n and i separated by a single space, where 0≤n≤1015 and 0≤i≤2n.
Output k lines. The j-th line must contain a single non-negative integer equal to cimod3 for the j-th data set.