The Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:

Given a number m, how many polynomials P with coefficients in set {\{0,1,2,3,4,5,6,7\}} have: P(2)=m?

Help Jerry Mao solve the long standing problem!

Input

The first line contains a single integer t (1 ≤ t ≤ 5⋅ 10^5) - number of test cases.

On next line there are t numbers, m_i (1 ≤ m_i ≤ 10^{18}) - meaning that in case i you should solve for number m_i.

Output

For each test case i, print the answer on separate lines: number of polynomials P as described in statement such that P(2)=m_i, modulo 10^9 + 7.

Example

Input


2
2 4


Output


2
4

Note

In first case, for m=2, polynomials that satisfy the constraint are x and 2.

In second case, for m=4, polynomials that satisfy the constraint are x^2, x + 2, 2x and 4.
#include <bits/stdc++.h>
using namespace std;
long long inf;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T, class T2>
long long chkmin(T &a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
template <class T, class T2>
long long chkmax(T &a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T, class T2>
T mmin(T a, T2 b) {
  return a < b ? a : b;
}
template <class T, class T2>
T mmax(T a, T2 b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
long long dcmp(T a, T b) {
  return a > b;
}
template <long long *a>
long long cmp_a(long long first, long long second) {
  return a[first] < a[second];
}
struct __INIT__ {
  __INIT__() {
    fill((unsigned char *)(&inf), (unsigned char *)(&inf) + sizeof(inf), 0x3f);
  }
} __INIT___;
namespace io {
const long long SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
long long f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char first) {
  *oS++ = first;
  if (oS == oT) flush();
}
template <typename A>
inline bool read(A &first) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (first = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    first = first * 10 + (c & 15);
  first *= f;
  return 1;
}
inline bool read(char &first) {
  while ((first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)) == ' ' ||
         first == '\n' || first == '\r')
    ;
  return first != EOF;
}
inline bool read(char *first) {
  while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                                (iS == iT ? EOF : *iS++))
                             : *iS++)) == '\n' ||
         *first == ' ' || *first == '\r')
    ;
  if (*first == EOF) return 0;
  while (!(*first == '\n' || *first == ' ' || *first == '\r' || *first == EOF))
    *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                           : *iS++);
  *first = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &first, B &...second) {
  return read(first) && read(second...);
}
template <typename A>
inline bool write(A first) {
  if (!first) putc('0');
  if (first < 0) putc('-'), first = -first;
  while (first) qu[++qr] = first % 10 + '0', first /= 10;
  while (qr) putc(qu[qr--]);
  return 0;
}
inline bool write(char first) {
  putc(first);
  return 0;
}
inline bool write(const char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
inline bool write(char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A first, B... second) {
  return write(first) || write(second...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
const unsigned p = 1000000007;
struct Z {
  unsigned first;
  Z() {}
  Z(unsigned a) { first = a; }
  Z &operator++() {
    first = first == p - 1 ? 0 : first + 1;
    return *this;
  }
  Z &operator--() {
    first = first ? first - 1 : p - 1;
    return *this;
  }
};
inline unsigned modp(const unsigned first) {
  return first < p ? first : first - p;
}
inline Z operator+(const Z x1, const Z x2) { return modp(x1.first + x2.first); }
inline Z operator-(const Z x1, const Z x2) {
  return modp(x1.first + p - x2.first);
}
inline Z operator-(const Z first) { return first.first ? p - first.first : 0; }
inline Z operator*(const Z x1, const Z x2) {
  return static_cast<unsigned long long>(x1.first) * x2.first % p;
}
void exgcd(long long a, long long b, long long &first, long long &second) {
  if (!b) {
    first = 1;
    second = 0;
    return;
  }
  exgcd(b, a % b, second, first);
  second -= (a / b) * first;
}
inline Z Inv(const Z first) {
  long long a, b;
  exgcd(p, first.first, a, b);
  return b < 0 ? b + p : b;
}
inline Z operator/(const Z x1, const Z x2) { return x1 * Inv(x2); }
inline Z &operator+=(Z &x1, const Z x2) { return x1 = x1 + x2; }
inline Z &operator-=(Z &x1, const Z x2) { return x1 = x1 - x2; }
inline Z &operator*=(Z &x1, const Z x2) { return x1 = x1 * x2; }
inline Z &operator/=(Z &x1, const Z x2) { return x1 = x1 / x2; }
unsigned long long f[7], g[7];
unsigned long long o[7][7], z[7][7];
void add1() {
  g[0] = (o[0][0] * f[0] + o[0][1] * f[1] + o[0][2] * f[2] + o[0][3] * f[3] +
          o[0][4] * f[4] + o[0][5] * f[5] + o[0][6] * f[6]) %
         p;
  g[1] = (o[1][0] * f[0] + o[1][1] * f[1] + o[1][2] * f[2] + o[1][3] * f[3] +
          o[1][4] * f[4] + o[1][5] * f[5] + o[1][6] * f[6]) %
         p;
  g[2] = (o[2][0] * f[0] + o[2][1] * f[1] + o[2][2] * f[2] + o[2][3] * f[3] +
          o[2][4] * f[4] + o[2][5] * f[5] + o[2][6] * f[6]) %
         p;
  g[3] = (o[3][0] * f[0] + o[3][1] * f[1] + o[3][2] * f[2] + o[3][3] * f[3] +
          o[3][4] * f[4] + o[3][5] * f[5] + o[3][6] * f[6]) %
         p;
  g[4] = (o[4][0] * f[0] + o[4][1] * f[1] + o[4][2] * f[2] + o[4][3] * f[3] +
          o[4][4] * f[4] + o[4][5] * f[5] + o[4][6] * f[6]) %
         p;
  g[5] = (o[5][0] * f[0] + o[5][1] * f[1] + o[5][2] * f[2] + o[5][3] * f[3] +
          o[5][4] * f[4] + o[5][5] * f[5] + o[5][6] * f[6]) %
         p;
  g[6] = (o[6][0] * f[0] + o[6][1] * f[1] + o[6][2] * f[2] + o[6][3] * f[3] +
          o[6][4] * f[4] + o[6][5] * f[5] + o[6][6] * f[6]) %
         p;
  f[0] = g[0];
  f[1] = g[1];
  f[2] = g[2];
  f[3] = g[3];
  f[4] = g[4];
  f[5] = g[5];
  f[6] = g[6];
}
void add0() {
  g[0] = (z[0][0] * f[0] + z[0][1] * f[1] + z[0][2] * f[2] + z[0][3] * f[3] +
          z[0][4] * f[4] + z[0][5] * f[5] + z[0][6] * f[6]) %
         p;
  g[1] = (z[1][0] * f[0] + z[1][1] * f[1] + z[1][2] * f[2] + z[1][3] * f[3] +
          z[1][4] * f[4] + z[1][5] * f[5] + z[1][6] * f[6]) %
         p;
  g[2] = (z[2][0] * f[0] + z[2][1] * f[1] + z[2][2] * f[2] + z[2][3] * f[3] +
          z[2][4] * f[4] + z[2][5] * f[5] + z[2][6] * f[6]) %
         p;
  g[3] = (z[3][0] * f[0] + z[3][1] * f[1] + z[3][2] * f[2] + z[3][3] * f[3] +
          z[3][4] * f[4] + z[3][5] * f[5] + z[3][6] * f[6]) %
         p;
  g[4] = (z[4][0] * f[0] + z[4][1] * f[1] + z[4][2] * f[2] + z[4][3] * f[3] +
          z[4][4] * f[4] + z[4][5] * f[5] + z[4][6] * f[6]) %
         p;
  g[5] = (z[5][0] * f[0] + z[5][1] * f[1] + z[5][2] * f[2] + z[5][3] * f[3] +
          z[5][4] * f[4] + z[5][5] * f[5] + z[5][6] * f[6]) %
         p;
  g[6] = (z[6][0] * f[0] + z[6][1] * f[1] + z[6][2] * f[2] + z[6][3] * f[3] +
          z[6][4] * f[4] + z[6][5] * f[5] + z[6][6] * f[6]) %
         p;
  f[0] = g[0];
  f[1] = g[1];
  f[2] = g[2];
  f[3] = g[3];
  f[4] = g[4];
  f[5] = g[5];
  f[6] = g[6];
}
signed main() {
  long long t;
  long long n;
  read(t);
  for (long long i = 0; i < 7; ++i) {
    for (long long j = 0; j <= 7; ++j) {
      if ((i + j) & 1)
        ++o[(i + j) >> 1][i];
      else
        ++z[(i + j) >> 1][i];
    }
  }
  for (; t; --t) {
    read(n);
    for (long long i = 1; i < 7; ++i) f[i] = 0;
    f[0] = 1;
    for (long long i = 0; i <= 60; ++i) {
      if ((n >> i) & 1)
        add1();
      else
        add0();
    }
    write(f[0], '\n');
  }
  return 0;
}
