A card pyramid of height 1 is constructed by resting two cards against each other. For h>1, a card pyramid of height h is constructed by placing a card pyramid of height h-1 onto a base. A base consists of h pyramids of height 1, and h-1 cards on top. For example, card pyramids of heights 1, 2, and 3 look as follows:

<image>

You start with n cards and build the tallest pyramid that you can. If there are some cards remaining, you build the tallest pyramid possible with the remaining cards. You repeat this process until it is impossible to build another pyramid. In the end, how many pyramids will you have constructed?

Input

Each test consists of multiple test cases. The first line contains a single integer t (1≤ t≤ 1000) — the number of test cases. Next t lines contain descriptions of test cases.

Each test case contains a single integer n (1≤ n≤ 10^9) — the number of cards.

It is guaranteed that the sum of n over all test cases does not exceed 10^9.

Output

For each test case output a single integer — the number of pyramids you will have constructed in the end.

Example

Input


5
3
14
15
24
1


Output


1
2
1
3
0

Note

In the first test, you construct a pyramid of height 1 with 2 cards. There is 1 card remaining, which is not enough to build a pyramid.

In the second test, you build two pyramids, each of height 2, with no cards remaining.

In the third test, you build one pyramid of height 3, with no cards remaining.

In the fourth test, you build one pyramid of height 3 with 9 cards remaining. Then you build a pyramid of height 2 with 2 cards remaining. Then you build a final pyramid of height 1 with no cards remaining.

In the fifth test, one card is not enough to build any pyramids.
#include <bits/stdc++.h>
using namespace std;
int ceilingOf(double a) {
  if (a == (int)a) return (int)a;
  return (int)a + 1;
}
int floorOf(double a) { return (int)a; }
long long maximum(long long x, long long y) {
  if (x > y) return x;
  return y;
}
int minimum(int x, int y) {
  if (x < y) return x;
  return y;
}
void shuffle_array(int arr[], int n) { random_shuffle(arr, arr + n); }
void print_array(int arr[], int n) {
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << '\n';
}
void print_array(bool arr[], int n) {
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << '\n';
}
void print_array(long long arr[], int n) {
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << '\n';
}
void swap(int* a, int* b) {
  int t = *a;
  *a = *b;
  *b = t;
}
void print_array(char** arr, int N, int M) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) cout << arr[i][j] << " ";
    cout << '\n';
  }
}
void print_array(int** arr, int N, int M) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) cout << arr[i][j] << " ";
    cout << '\n';
  }
}
void print_array(long long** arr, int N, int M) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) cout << arr[i][j] << " ";
    cout << '\n';
  }
}
int floodArea(int N, int M, bool** pos, bool** visited, int i, int j) {
  if (pos[i][j] == 0) return 0;
  list<int> a;
  int maxar = -INT_MAX;
  visited[i][j] = 1;
  a.push_back((N + M) * i + j);
  int counts = 1;
  while (!a.empty()) {
    int index = a.back();
    a.pop_back();
    int row = index / (M + N);
    int col = index % (M + N);
    if ((row + 1 < N) && visited[row + 1][col] == 0 &&
        pos[row + 1][col] == pos[i][j]) {
      visited[row + 1][col] = 1;
      a.push_back((M + N) * (row + 1) + col);
      counts++;
    }
    if ((col + 1 < M) && visited[row][col + 1] == 0 &&
        pos[row][col + 1] == pos[i][j]) {
      visited[row][col + 1] = 1;
      a.push_back((M + N) * row + (col + 1));
      counts++;
    }
    if ((row - 1 >= 0) && visited[row - 1][col] == 0 &&
        pos[row - 1][col] == pos[i][j]) {
      visited[row - 1][col] = 1;
      a.push_back((M + N) * (row - 1) + col);
      counts++;
    }
    if ((col - 1 >= 0) && visited[row][col - 1] == 0 &&
        pos[row][col - 1] == pos[i][j]) {
      visited[row][col - 1] = 1;
      a.push_back((M + N) * row + (col - 1));
      counts++;
    }
  }
  if (counts > maxar) {
    maxar = counts;
  }
  return maxar;
}
void deleteFlood(int N, int M, int** pos, int** visited, int i, int j) {
  int val = pos[i][j];
  pos[i][j] = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) visited[i][j] = 0;
  list<int> a;
  int maxar = -INT_MAX;
  visited[i][j] = 1;
  a.push_back((N + M) * i + j);
  int counts = 1;
  while (!a.empty()) {
    int index = a.back();
    a.pop_back();
    int row = index / (M + N);
    int col = index % (M + N);
    if ((row + 1 < N)) {
      if (visited[row + 1][col] == 0 && pos[row + 1][col] == val) {
        visited[row + 1][col] = 1;
        a.push_back((M + N) * (row + 1) + col);
        pos[row + 1][col] = 0;
      }
    }
    if ((col + 1 < M)) {
      if (visited[row][col + 1] == 0 && pos[row][col + 1] == val) {
        visited[row][col + 1] = 1;
        a.push_back((M + N) * row + (col + 1));
        pos[row][col + 1] = 0;
      }
    }
    if ((row - 1 >= 0)) {
      if (visited[row - 1][col] == 0 && pos[row - 1][col] == val) {
        visited[row - 1][col] = 1;
        a.push_back((M + N) * (row - 1) + col);
        pos[row - 1][col] = 0;
      }
    }
    if ((col - 1 >= 0)) {
      if (visited[row][col - 1] == 0 && pos[row][col - 1] == val) {
        visited[row][col - 1] = 1;
        a.push_back((M + N) * row + (col - 1));
        pos[row][col - 1] = 0;
      }
    }
  }
}
void print_vector(vector<int> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<char> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<long long> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<double> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<int> amount, int N) {
  for (auto i = amount.begin(); i != amount.begin() + N; i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<string> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<bool> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_vector(vector<pair<int, int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).first << " ";
  cout << '\n';
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).second << " ";
  cout << '\n';
}
void print_vector(vector<pair<long long, long long>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).first << " ";
  cout << '\n';
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).second << " ";
  cout << '\n';
}
void print_vector(vector<pair<string, int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).first << " " << (*i).second << '\n';
  cout << '\n';
}
void print_vector(vector<pair<pair<int, int>, int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).first.first << " " << (*i).first.second << " " << (*i).second
         << '\n';
  cout << '\n';
}
void print_vector(vector<pair<int, pair<int, int>>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << (*i).first << " " << (*i).second.first << " " << (*i).second.second
         << '\n';
  cout << '\n';
}
void print_vector(vector<tuple<int, int, int, int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << get<0>(*i) << " " << get<1>(*i) << " " << get<2>(*i) << " "
         << get<3>(*i) << '\n';
  cout << '\n';
}
void print_vector(vector<vector<string>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<long long>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<pair<long long, long long>>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
  }
  cout << '\n';
}
void print_vector(vector<vector<vector<int>>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<vector<long long>>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<bool>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    print_vector(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_set(set<int> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_set(set<pair<int, int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++)
    cout << i->first << " " << i->second << '\n';
  cout << '\n';
}
void print_vector(vector<set<int>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_set(*i);
    cout << '\n';
  }
  cout << '\n';
}
void print_vector(vector<vector<pair<int, int>>> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) {
    cout << i - amount.begin() << '\n';
    print_vector(*i);
  }
}
void print_set(set<string> amount) {
  for (auto i = amount.begin(); i != amount.end(); i++) cout << *i << " ";
  cout << '\n';
}
void print_map(map<int, vector<int>> m) {
  for (map<int, vector<int>>::iterator i = m.begin(); i != m.end(); i++) {
    cout << i->first << " ";
    print_vector(i->second);
  }
}
void print_map(map<string, vector<string>> m) {
  for (map<string, vector<string>>::iterator i = m.begin(); i != m.end(); i++) {
    cout << i->first << " ";
    print_vector(i->second);
  }
}
void print_map(map<string, vector<bool>> m) {
  for (map<string, vector<bool>>::iterator i = m.begin(); i != m.end(); i++) {
    cout << i->first << " ";
    print_vector(i->second);
  }
}
void print_map(map<string, set<string>> m) {
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first << " ";
    print_set(i->second);
  }
}
void print_map_vector(map<string, vector<bool>> m) {
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first << " ";
    print_vector(i->second);
  }
}
void print_map(map<int, bool> m) {
  for (map<int, bool>::iterator i = m.begin(); i != m.end(); i++) {
    cout << i->first << " " << i->second << '\n';
  }
}
void print_map(map<int, int> m) {
  for (map<int, int>::iterator i = m.begin(); i != m.end(); i++) {
    cout << i->first << " " << i->second << '\n';
  }
}
void print_map(map<char, vector<string>> m) {
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first << '\n';
    cout << '\t';
    print_vector(i->second);
  }
}
void print_map(map<char, int> m) {
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first << '\n';
    cout << '\t' << i->second << '\n';
  }
}
void print_map(map<pair<int, int>, int> m) {
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first.first << " " << i->first.second << " " << i->second
         << '\n';
  }
}
bool comp(pair<int, int> x, pair<int, int> y) {
  if (x.second > y.second) {
    return 0;
  }
  if (x.second == y.second) {
    return x.first < y.first;
  }
  return 1;
}
class segment_tree {
  vector<int> tree;
  int height;
  int maxSize;
  int STARTINDEX = 0;
  int ENDINDEX;

 public:
  segment_tree(int n) {
    height = (int)ceilingOf(log2(n));
    maxSize = (1 << (height + 1)) - 1;
    tree.resize(maxSize);
    ENDINDEX = (1 << height) - 1;
  }

 public:
  int leftChild(int k) { return 2 * k + 1; }

 public:
  int rightChild(int k) { return 2 * k + 2; }

 public:
  void buildSegTree(vector<int>& A) {
    A.resize(1 << height, 0);
    buildSegTreeRec(STARTINDEX, ENDINDEX, 0, A);
  }

 public:
  int buildSegTreeRec(int low, int high, int p, vector<int>& A) {
    if (low == high) {
      tree[p] = A[low];
      return tree[p];
    }
    int mid = (low + high) / 2;
    tree[p] = buildSegTreeRec(low, mid, leftChild(p), A) +
              buildSegTreeRec(mid + 1, high, rightChild(p), A);
    return tree[p];
  }

 public:
  int getSum(int x, int y) {
    if (x < 0 || ENDINDEX < y) return -INT_MAX;
    return getSumRec(STARTINDEX, ENDINDEX, x, y, 0);
  }

 public:
  int getSumRec(int low, int high, int x, int y, int p) {
    if (x <= low && high <= y) return tree[p];
    if (y < low || high < x) return 0;
    int mid = (low + high) / 2;
    return getSumRec(low, mid, x, y, leftChild(p)) +
           getSumRec(mid + 1, high, x, y, rightChild(p));
  }

 public:
  void addValue(int pos, int val) {
    addValueRec(STARTINDEX, ENDINDEX, pos, val, 0);
  }

 public:
  void addValueRec(int low, int high, int pos, int val, int p) {
    if (low <= pos && pos <= high) {
      tree[p] = tree[p] + val;
      if (low != high) {
        int mid = (low + high) / 2;
        addValueRec(low, mid, pos, val, leftChild(p));
        addValueRec(mid + 1, high, pos, val, rightChild(p));
      }
    }
  }

 public:
  void print() { print_vector(tree); }
};
class max_tree {
  vector<int> tree;
  int counts = 0;
  int height;
  int maxSize;
  int STARTINDEX = 0;
  int ENDINDEX;

 public:
  max_tree(int n) {
    height = (int)ceilingOf(log2(n));
    maxSize = (1 << (height + 1)) - 1;
    tree.resize(maxSize);
    ENDINDEX = (1 << height) - 1;
  }

 public:
  int leftChild(int k) { return 2 * k + 1; }

 public:
  int rightChild(int k) { return 2 * k + 2; }

 public:
  void build_max_tree(vector<int>& A) {
    A.resize(1 << height, 0);
    buildSegTreeRec(STARTINDEX, ENDINDEX, 0, A);
  }

 public:
  int buildSegTreeRec(int low, int high, int p, vector<int>& A) {
    if (low == high) {
      tree[p] = A[low];
      return tree[p];
    }
    int mid = (low + high) / 2;
    tree[p] = max(buildSegTreeRec(low, mid, leftChild(p), A),
                  buildSegTreeRec(mid + 1, high, rightChild(p), A));
    return tree[p];
  }

 public:
  int get_max(int x, int y) {
    if (x < 0 || ENDINDEX < y) return -INT_MAX;
    return get_max1(STARTINDEX, ENDINDEX, x, y, 0);
  }

 public:
  int get_max1(int low, int high, int x, int y, int p) {
    if (x <= low && high <= y) return tree[p];
    if (y < low || high < x) return 0;
    int mid = (low + high) / 2;
    return max(get_max1(low, mid, x, y, leftChild(p)),
               get_max1(mid + 1, high, x, y, rightChild(p)));
    ;
  }

 public:
  void addValue(int pos, int val) {
    addValueRec(STARTINDEX, ENDINDEX, pos, val, 0);
  }

 public:
  void addValueRec(int low, int high, int pos, int val, int p) {
    if (low <= pos && pos <= high) {
      tree[p] = tree[p] + val;
      if (low != high) {
        int mid = (low + high) / 2;
        addValueRec(low, mid, pos, val, leftChild(p));
        addValueRec(mid + 1, high, pos, val, rightChild(p));
      }
    }
  }

 public:
  void print() { print_vector(tree); }
};
class FenwickTree {
 private:
  vector<int> ft;

 public:
  FenwickTree(int n) { ft.assign(n + 1, 0); }
  int rsq(int b) {
    int sum = 0;
    for (; b; b -= b & (-b)) sum += ft[b];
    return sum;
  }
  int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }
  void adjust(int k, int v) {
    for (; k < (int)ft.size(); k += k &= (-k)) ft[k] += v;
  }
  void print() { print_vector(ft); }
};
struct Graph {
  int V, E;
  vector<pair<int, pair<int, int>>> edges;
  Graph(int a, int b) {
    V = a;
    E = b;
  }
  void addEdge(int a, int b, int w) { edges.push_back({w, {a, b}}); }
  vector<int> links, sizes;
  int find(int a) {
    if (a == links[a]) return a;
    return links[a] = find(links[a]);
  }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (sizes[a] < sizes[b]) swap(a, b);
    sizes[a] += sizes[b];
    links[b] = a;
  }
  void sort_edges() { sort(edges.begin(), edges.end()); }
  long long kruskalMST() {
    sort_edges();
    links.resize(V);
    sizes.resize(V);
    for (int i = 0; i < V; i++) {
      links[i] = i;
      sizes[i] = 1;
    }
    long long sum = 0;
    int count = 0;
    for (int i = (0); i < (E); ++i) {
      int start = edges[i].second.first;
      int end = edges[i].second.second;
      if (!same(start, end)) {
        unite(start, end);
        sum += edges[i].first;
        count++;
      }
    }
    if (count != V - 1) return -1000000007;
    return sum;
  }
};
bool comparator(long long a, long long b) { return a > b; }
long long a, b, c;
int t;
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
}
vector<int> triangles;
int solve(int n) {
  if (n <= 1) return 0;
  a = upper_bound(triangles.begin(), triangles.end(), n) - triangles.begin();
  a--;
  return solve(n - triangles[a]) + 1;
}
int n;
int main() {
  init();
  triangles.reserve(100000);
  int val = 2;
  int index = 1;
  while (val < 1000000000) {
    triangles.push_back(val);
    index++;
    val = (3 * index * index + index) / 2;
  }
  for (int l = (0); l < (t); ++l) {
    cin >> n;
    cout << solve(n) << '\n';
  }
}
