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;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1 << 20;
namespace io {
const int SIZE = 1e7 + 10;
char inbuff[SIZE];
char *l, *r;
inline void init() {
  l = inbuff;
  r = inbuff + fread(inbuff, 1, SIZE, stdin);
}
inline char gc() {
  if (l == r) init();
  return (l != r) ? *(l++) : EOF;
}
void read(int &x) {
  x = 0;
  char ch = gc();
  while (!isdigit(ch)) ch = gc();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
}
void read(long long &x) {
  x = 0;
  char ch = gc();
  while (!isdigit(ch)) ch = gc();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
}
}  // namespace io
using io::read;
long long m;
int dp[64][8];
int get_bit(long long x, int v) { return (x >> v) & 1; }
void my_add(int &x, int v) {
  x += v;
  if (x >= MOD) x -= MOD;
}
void my_sub(int &x, int v) {
  x -= v;
  if (x < 0) x += MOD;
}
void solve() {
  memset((dp), 0, sizeof((dp)));
  dp[60][0] = 1;
  for (int i = 59; i >= 0; i--) {
    for (int j = 0; j < (8); ++j) {
      int v = (j << 1) + get_bit(m, i);
      my_add(dp[i][max(0, v - 7)], dp[i + 1][j]);
      if (v < 7) my_sub(dp[i][v + 1], dp[i + 1][j]);
    }
    for (int j = (1); j < (8); ++j) {
      my_add(dp[i][j], dp[i][j - 1]);
    }
  }
  W(dp[0][0]);
}
void input() {
  m = 1000000000000000000LL;
  read(m);
}
int main() {
  int T;
  read(T);
  while (T--) {
    input();
    solve();
  }
  return 0;
}
