A professor has built the Atomic Computer, which runs 8,000,000,000 times faster than a normal computer. It keeps values in a special memory where one bit represents one of three states, -1, 0 and 1.
Write the bits of a y bit memory as dy−1,dy−2,…,d1,d0, starting from the front. The value held by the memory is
∑i=0y−1di⋅2i
Each di is -1, 0 or 1. For example, (1)(−1)(0)2 holds 1⋅4+(−1)⋅2+0⋅1=2. The number of bits is always exactly y, and a representation whose leading bits are 0 counts as its own way of storing the value.
Given an integer x to store and the number of bits y, count the ways to store x in y bits.
The first line contains the number of test cases T. (T≥1)
Each of the next T lines contains two integers xi and yi, where xi is the value to store and yi is the number of bits. (−2000000000≤xi≤2000000000, 1≤yi≤20)
Print T lines. The ith line contains the number of ways to store xi in yi bits.