Atomic Computer

No attempts yetTime limit1sMemory limit256 MB

Problem

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 yy bit memory as dy1,dy2,,d1,d0d_{y-1}, d_{y-2}, \dots, d_1, d_0, starting from the front. The value held by the memory is

i=0y1di2i\sum_{i=0}^{y-1} d_i \cdot 2^{i}

Each did_i is -1, 0 or 1. For example, (1)(1)(0)2(1)(-1)(0)_2 holds 14+(1)2+01=21 \cdot 4 + (-1) \cdot 2 + 0 \cdot 1 = 2. The number of bits is always exactly yy, and a representation whose leading bits are 0 counts as its own way of storing the value.

Given an integer xx to store and the number of bits yy, count the ways to store xx in yy bits.

Input

The first line contains the number of test cases TT. (T1T \ge 1)

Each of the next TT lines contains two integers xix_i and yiy_i, where xix_i is the value to store and yiy_i is the number of bits. (2000000000xi2000000000-2000000000 \le x_i \le 2000000000, 1yi201 \le y_i \le 20)

Output

Print TT lines. The iith line contains the number of ways to store xix_i in yiy_i bits.