#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
int pow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % 1000000007;
    x = 1ll * x * x % 1000000007;
    y >>= 1;
  }
  return ret;
}
template <class Ta, class Tb>
void inc(Ta& a, Tb b) {
  a = a + b >= 1000000007 ? a + b - 1000000007 : a + b;
}
template <class Ta, class Tb>
void dec(Ta& a, Tb b) {
  a = a >= b ? a - b : a + 1000000007 - b;
}
long long f[63][9];
int main() {
  int T = gi();
  while (T--) {
    long long m = gi();
    memset(f, 0, sizeof f);
    f[0][0] = 1;
    f[0][1] = -1;
    for (int i = 0; i <= 60; ++i) {
      int d = m >> i & 1;
      long long s = 0;
      if (i % 10 == 0)
        for (int j = 0; j < 8; ++j) f[i][j] %= 1000000007;
      for (int j = 0; j < 8; ++j) {
        s += f[i][j];
        f[i + 1][j + (j + d & 1) >> 1] += s;
        f[i + 1][j + (j + d & 1) + 8 >> 1] -= s;
      }
    }
    printf("%lld\n", f[61][0] % 1000000007);
  }
  return 0;
}
