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>
#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1);
double isp = 1e-13;
const int INF = 0x3f3f3f3f;
using namespace std;
long long qpow(long long a, long long b, long long MOD = mod) {
  for (long long ans = 1;; a = a * a % MOD, b >>= 1) {
    if (b & 1) ans = ans * a % MOD;
    if (!b) return ans;
  }
}
long long inv(long long a, long long MOD = mod) {
  return qpow(a, MOD - 2, MOD);
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long ret = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return ret;
}
long long getInv(int a, int mod) {
  long long x, y;
  long long d = exgcd(a, mod, x, y);
  return d == 1 ? (x % mod + mod) % mod : -1;
}
int dp[61][9];
int a[N];
char BUF[1 << 22], *ST, *EN;
template <class T>
void read(T &x) {
  int f = 0;
  x = 0;
  char ch = (ST == EN && (ST = BUF, EN = BUF + fread(BUF, 1, 1 << 21, stdin),
                          ST == EN)
                 ? EOF
                 : *ST++);
  for (; !isdigit(ch);
       ch = (ST == EN && (ST = BUF, EN = BUF + fread(BUF, 1, 1 << 21, stdin),
                         ST == EN)
                 ? EOF
                 : *ST++))
    f |= (ch == '-');
  for (; isdigit(ch);
       ch = (ST == EN && (ST = BUF, EN = BUF + fread(BUF, 1, 1 << 21, stdin),
                         ST == EN)
                 ? EOF
                 : *ST++))
    x = x * 10 + ch - '0';
  if (f) x = -x;
}
inline const void add(int &x, const int y) {
  x = (x + y >= mod ? x + y - mod : x + y);
}
int main() {
  int t;
  read(t);
  while (t--) {
    long long m;
    read(m);
    int mx = 0;
    for (int i = 0; i < 60; i++) {
      if (m & 1)
        a[i] = 1, mx = i;
      else
        a[i] = 0;
      m >>= 1;
    }
    memset(dp, 0, sizeof dp);
    dp[mx + 1][0] = 1;
    for (int i = mx; i >= 0; i--) {
      for (int j = 0; j <= 8; j++)
        if (dp[i + 1][j]) {
          int now = 2 * j + a[i];
          if (now < 8) add(dp[i][now + 1], mod - dp[i + 1][j]);
          add(dp[i][now - min(now, 7)], dp[i + 1][j]);
        }
      for (int k = 1; k <= 8; k++) add(dp[i][k], dp[i][k - 1]);
    }
    printf("%d\n", dp[0][0]);
  }
}
