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.
/* -
Legends - A: An Array.
          S: A String Array
          n: Size of the Array A.
          x: an integer variable.
The List of Functions in the Library
1. Take input in an Integer Array - ob.ar_iin(n);
1.5 Take input in an Long Array - ob.sr_lin(n);
2. Take input in an String Array - ob.ar_sin(n);
3. Take input in an Character Array - ob.ar_cin(n);
4. Take input in an Double Array - ob.ar_din(n);
5. Print the content of an int Array - ob.print_iarr(A);
6. Print the content of an String Array - ob.print_sarr(A);
7. Print the content of a Character Array - ob.print_carr(A);
8. Print the content of a Double Array - ob.print_darr(A);
9. Get the sum of an Integer Array - ob.ar_sum(A);
10. Get the Maximum in an Array  - ob.ar_max(A);
12. Get the Minimum in an Array - ob.ar_min(A);
13. Get the Number of Digits in an Integer - ob.idigits(x);
14. Get an Integer Input - ob.iin();
15. Get a String Input - ob.sin();
*/

import java.io.*;
import java.util.*;
public class pyramids
{

// Write Your Program in the main method below! 
public static void main(String[] args)throws Exception
{ 
    pyramids ob= new pyramids();
    long test=ob.iin();
    long[] A= new long [32000];
    A[1]=2;A[0]=0;

    for(int i=2;i<32000;i++)
     A[i]=((i*(i+1)/2)*3)-i;
    
     String ans="";
    while(test-->0)
    {
        long n=ob.iin();
        if(n==1000000000)
         {System.out.println(ans+"6\n"); continue;}
        int x=(int) Math.floor(Math.sqrt(n)); 
        long c=0; int i=x;
        while(i>=1 && n>0)
        {
            if(n>=A[i])
            {
             c++; n=n-A[i];
            }
            else
             i--;  
        }
        ans=ans+c+"\n";
    } 
    ans=ans.trim();
    System.out.println(ans);
}

  // *********** Below are the library functions, just refer the Legends at the start of the Program to use them.

  public int iin()throws Exception
  {
    DataInputStream in = new DataInputStream(System.in);
    int n = Integer.parseInt(in.readLine());
    return n;
  }
  
  public long lin()throws Exception
  {
    DataInputStream in = new DataInputStream(System.in);
    long n = Long.parseLong(in.readLine());
    return n;
  }
  public String sin()throws Exception
  {
    DataInputStream in = new DataInputStream(System.in);
    String s = in.readLine();
    return s;
  }
          
  public int[] ar_iin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    int A[] = new int[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Integer.parseInt(strs[i]);
    return A;
  }

  public long[] ar_lin(int n)throws Exception
  { //Take Long Array as Input
    DataInputStream in = new DataInputStream(System.in);
    String line = in.readLine();
    long A[] = new long[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Long.parseLong(strs[i]);
    return A;
  }

  public String[] ar_sin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    String strs[] = line.trim().split(" ");
    return strs;
  }

  public char[] ar_cin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    char A[] = new char[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = (strs[i]).charAt(0);
    return A;
  }

  public double[] ar_din(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    double A[] = new double[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Double.parseDouble(strs[i]);
    return A;
  }

  public void print_iarr(int A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_sarr(String A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_carr(char A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_darr(double A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }
  public int ar_sum(int A[])
  { //Find sum of element in an Array
    int sum=0;
    for(int i=0;i<A.length;i++)
     sum=sum+A[i];
    return sum;
  }

  public int ar_max(int A[])
  {
    int max=A[0];
    for(int i=0;i<A.length;i++)
     max=max>A[i]?max:A[i];
    return max;
  }

  public int ar_min(int A[])
  {
    int min=A[0];
    for(int i=0;i<A.length;i++)
     min=min<A[i]?min:A[i];
    return min;
  }

  public int idigits(int n)
  {
    return (int)Math.floor(Math.log10(n) + 1);
  }

  public int[] freq(String n)
  {
    n=n.toLowerCase();
    int A[] = new int[26];
    int len = n.length();
    for(int i=0;i<len;i++){
      char a = n.charAt(i);
      int temp = (int)a;
      int val = temp-97;
      A[val]++;
    }
    return A;
  }

}