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: $\wedge A A$ 

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\le t\le 1000$) — the number of test cases. Next $t$ lines contain descriptions of test cases.

Each test case contains a single integer $n$ ($1\le n\le 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.

Difficulty: interview

Starter code:

Solutions:
for zz in range(int(input())):
    n = int(input())
    ans = 0
    while n > 1:
        ans += 1
        cr = 2
        while n >= cr:
            n -= cr
            cr += 3
    print(ans)


import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: list(map(int, readline().split()))
nl = lambda: list(map(int, readline().split()))

def solve():
    n = ni()
    ans = 0
    while n > 1:
        ok, ng = 0, 10**5
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if mid*(mid+1)*3//2 - mid <= n:
                ok = mid
            else:
                ng = mid
        n -= ok*(ok+1)*3//2 - ok
        ans += 1
    print(ans)


# solve()

T = ni()
for _ in range(T):
    solve()


import sys
import heapq
import math
import bisect

def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def rinput():
    return map(int, input().split())

def rlinput():
    return list(map(int, input().split()))

def srlinput():
    return sorted(list(map(int, input().split())))

q = [2]
i = 2
while q[-1] < 1e9:
    q.append(q[-1] + 2 * i + i - 1)
    i +=1
def main():
    n = iinput()
    res = 0
    while n >= q[0]:
        #print(bisect.bisect_right(q, n) - 1, q[bisect.bisect_right(q, n) - 1], n)
        n -= q[bisect.bisect_right(q, n) -1]
        res += 1
    print(res)
    

    
            
for sdfghjkl in range(iinput()):
    main()

import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('B.txt').readlines())
	def input():
		return next(f)
else:
	input = sys.stdin.readline

def func(k):
	return (k * (k + 1)) // 2 * 3 - k

t = int(input())
for _ in range(t):
	n = int(input())
	
	res = 0
	k = 1
	while func(k) <= n:
		k += 1
	while n > 0:
		while k > 0 and func(k) > n:
			k -= 1
		if k != 0:
			res += 1
			n -= func(k)
		else:
			break
	print(res)

poss=[2]
i=2
while poss[-1]<=1000000000:
    poss.append(poss[-1]+2*i+i-1)
    i+=1
for f in range(int(input())):
    n=int(input())
    m=0
    i=0
    while poss[i+1]<=n:
        i+=1
    n-=poss[i]
    if n>=0:
        m+=1
    while n>1:
        while poss[i]>n:
            i-=1
        n-=poss[i]
        m+=1
    print(m)

import bisect

list=[]
for i in range(1,10**5):
    list.append((3*i**2+i)//2)

for _ in range(int(input())):
    n=int(input())
    count=0
    while n>=2:
        r=bisect.bisect_right(list,n)
        n-=list[r-1]
        count+=1
    print(count)


t = int(input())
for q in range(0, t):
    n = int(input())
    number = 0
    while n > 1:
        left = 1
        right = n
        while right - left > 1:
            m = (right + left) // 2
            if 3 * m * (m + 1) // 2 - m > n:
                right = m
            else:
                left = m
        n -= (3 * left * (left + 1) // 2 - left)
        number += 1
    print(number)


# Contest No.: 639
# Problem No.: B
# Solver:      JEMINI
# Date:        20200503

import sys

def main():
    t = int(input())
    for _ in range(t):
        n = int(sys.stdin.readline().strip())
        ans = 0
        while n > 1:
            cnt = 1
            temp = 2
            while n >= (temp + cnt + 2 * (cnt + 1)):
                temp += cnt + 2 * (cnt + 1)
                cnt += 1
            n -= temp
            ans += 1
        print(ans)
        
    return

def __starting_point():
    main()
__starting_point()

T = int(input())
p = []
i = 0
np = 0
while np < 10 ** 9:
   i += 1
   np += 3 * i - 1
   p.append(np)
for case in range(T):
	t = int(input())
	c = 0
	while t >= 2:
	   for e in p[::-1]:
	      if t >= e:
	         t -= e
	         c += 1
	         break
	
	
	print(c)


T = int(input())

for tc in range(T):
    n = int(input())
    count = 0
    while(n>=2):
        h = (-1 + (1 + 24*n)**0.5)//6
        stack_cards = (3*(h**2) + h)//2
        count+=1
        n = n - stack_cards

    print(count)


def generatepyramids():
    start = 2
    total = 2
    pyramids = [0, 2]
    for i in range(40000):
        start += 3
        total += start
        pyramids.append(total)
    return pyramids

def largestpyramid(n, pyramids):
    lo = 0
    hi = len(pyramids)
    mid = (lo + hi) // 2
    while lo != hi:
        mid = (lo + hi) // 2
        cur_pyramid = pyramids[mid]
        if cur_pyramid <= n:
            lo = mid + 1
        else:
            hi = mid
    if cur_pyramid <= n:
        return pyramids[mid]
    else:
        return pyramids[mid-1]

pyramids = generatepyramids()
t = int(input())
for case in range(t):
    n = int(input())
    answer = 0
    while n > 1:
        cur = largestpyramid(n, pyramids)
        n -= cur
        answer += 1
    print (answer)
        

    


t = int(input())
for i in range(t):
    n = int(input())
    cnt = 0
    while n > 1:
        h = 1
        now = 2
        while n >= now + 2 * (h + 1) + h:
            now += (h + 1) * 2 + h
            h += 1
        n -= now
        cnt += 1
    print(cnt)

t=int(input())
for tt in range(t):
	x=int(input())
	temp=x
	cc=0
	while temp>0:
		start=0
		end=temp
		ans=0
		while start<=end:
			mid=(start)+(end-start)//2
			xx=mid*((3*mid)+1)//2
			if xx<=temp:
				start=mid+1
				ans=max(ans,mid)
			else:
				end=mid-1
		if ans==0:
			break
		temp-=(ans*((3*ans)+1))//2
		cc+=1
	print(cc)

import sys
# from collections import deque

# print(help(deque))
# 26
input = lambda: sys.stdin.readline().strip()
ipnut = input
dp = [0]
n = 0
while dp[-1]<1000000000:
    n+=1
    dp.append(n*(3*n+1)//2)
# print(dp[:10])
for i in range(int(input())):
    n = int(input())
    # s = list(map(int,input()))
    k = 0
    while n>1:
        k+=1
        l = 0
        r = len(dp)
        while r-l>1:
            m = (r+l)//2
            if dp[m]<=n:
                l = m
            else:
                r = m
        n-=dp[l]
    print(k)
"""
10
10 11 12 13 14 15 16 17 11 11
"""

for i in range(int(input())):
    n = int(input())
    c = 0
    while n > 1:
        l = 0
        r = 1000000
        while r - l != 1:
            s = (l + r) // 2
            if s*(3*s + 1) // 2 > n:
                r = s
            else:
                l = s
        c += 1
        n -= l*(3*l + 1) // 2
    print(c)


arr = []
n = 1
while 1:
    v = n*(n+1)//2*3 - n
    if v > 10**9: break
    arr.append(v)
    n += 1

from bisect import bisect
T = int(input())
for _ in range(T):
    N = int(input())
    ans = 0
    while N >= 2:
        i = bisect(arr,N)
        v = arr[i-1]
        N -= v
        ans += 1
    print(ans)


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    t = int(input())
    for _ in range(t):
        n = int(input())

        cnt = 0
        while n > 1:
            i = 0
            while i <= n * n:
                i += 1
                total = i * (i + 1) + (i * (i - 1)) // 2
                if total > n:
                    break
            i -= 1
            n -= i * (i + 1) + (i * (i - 1)) // 2
            i = 1
            cnt += 1
        print(cnt)
    return

def __starting_point():
    main()
__starting_point()

for i in range(int(input())):
    n = int(input())
    n = n
    ans = 0
    while n >= 2:
        ch = 2
        deff = 5
        while ch + deff <= n:
            ch += deff
            deff += 3
        ans += 1
        n -= ch
    print(ans)

t = int(input())
for _ in range(t):
    n = int(input())

    def f(x): return ((3 * (x + 1) * x) // 2) - x

    ans = 0
    while n > 1:
        left, right = 1, int(1e5)
        while left < right:
            mid = (left + right + 1) // 2
            if f(mid) > n:
                right = mid - 1
            else:
                left = mid

        n -= f((left+right + 1)//2)
        ans += 1
    print(ans)


def calc(n):
	return 3*((n*(n+1)))//2 - n
def binSearch(start, end, num):
	mid = (start+end)//2
	a = calc(mid)
	b = calc(mid + 1)
	if(a<=num and b>num):
		return a
	elif(a<num):
		return binSearch(mid+1, end, num)
	return binSearch(start, mid-1, num)
for tt in range(int(input())):
	n = int(input())
	c = 0
	while(n>1):
		n -= binSearch(1, n, n)
		c+=1
	print(c)

for _ in range(int(input())):
    n = int(input())
    x = 0
    while (3 * x * x + x) // 2 < n:
        x += 1
    ans = 0
    while n > 1:
        if (3 * x * x + x) // 2 <= n:
            n = n - (3 * x * x + x) // 2
            ans += 1
        else:
            x -= 1
    print(ans)

import math
t = int(input())
import math
delay = []
for _ in range(t):
    n = int(input())
    k = 0
    while(n > 0):
        x = math.floor(((24*n+1)**(0.5) - 1)/6)
        if x <= 0:
            break
        n -= x*(3*x+1)/2
        k+=1 
    print(k)

import sys
T = int(sys.stdin.readline().strip())

cache = [2]
L = 1

for t in range(T):
    n = int(sys.stdin.readline().strip())
    while cache[-1] < n:
        L += 1
        cache.append(L*(L+1) + L * (L-1)//2)
    l = 0; r = L
    while l < r-1:
        m = (l+r)//2
        if cache[m] <= n and( m+1 == L or cache[m+1] > n): l = m; break
        if cache[m] < n: l = m
        else: r = m
    cnt = 0
    while l >= 0 and n > 1:
        if n >= cache[l]: n -= cache[l]; cnt += 1
        else: l -= 1
    print(cnt)


from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################
from bisect import bisect_right
s=[2]
for h in range(2,40000):
	s.append(s[-1]+3*h-1)
def main():
	n=aint()
	ans=0
	while n>=2:
		i=bisect_right(s,n)
		#print(i,s[i],n)
		n-=s[i-1]
		ans+=1
	print(ans)
	#solve

t=int(input())

########################################################
for i in range(t):                                     #
	#print("Case #"+str(i+1)+":",end=" ")		       #
	main()                                             #

'''


5
3
14
15
24
1



'''

n=int(input())
L=[2,7]
S=8;
for i in range(1,100000):
    L.append(L[i]+S);
    S+=3;
for i in range(0,n):
    o=int(input())
    tot=0;
    while(1):
        I=0;
        V=-1;
        J=len(L)-1;
        while(I<=J):
            m=(I+J)//2;
            if L[m]>o:
                J=m-1;
            else:
                V=m;
                I=m+1;
        if V!=-1:
            tot+=1;
            o-=L[V];
        else:
            break;
    print(tot)

pref = [2]
for i in range(2, 30000):
    pref.append(i*3-1)
    pref[-1]+= pref[-2]
t = int(input())

for uuu in range(t):
    n = int(input())
    cnt = 0
    while(n>1):
        l = 0
        r = 30000
        while(r-l > 1):
            mid = (r+l)//2
            if(pref[mid] > n):
                r = mid
            else:
                l = mid
        n -= pref[l]
        cnt+=1
    print(cnt)

def check(x,n):
    used = 2*x
    used += (3*x*(x-1)//2)

    if used <= n:
        return True

    return False

def find(n):
    low = 0
    high = n
    h = 0
    while low <= high:
        mid = (low+high)//2
        if check(mid,n):
            h = mid
            low = mid+1
        else:
            high = mid-1

    used = 2*h
    used += 3*h*(h-1)//2
    return used

def solve(n,ans):
    total = 0
    while n > 0:
        used = find(n)
        #print(used)
        if used > 0:
            total += 1
            n -= used
        else:
            break

    ans.append(total)

def main():
    t = int(input())
    ans = []
    for i in range(t):
        n = int(input())
        solve(n,ans)

    for i in ans:
        print(i)
        


main()


import sys

input = sys.stdin.readline


def pyramid(n, l, r):
    if l == r:
        return l
    mid = (l + r + 1) // 2
    if (3 * mid * mid + mid) // 2 > n:
        return pyramid(n, l, mid - 1)
    else:
        return pyramid(n, mid, r)

for _ in range(int(input())):
    n = int(input())
    cnt = 0
    while n >= 2:
        x = pyramid(n, 1, n)
        n -= (3 * x * x + x) // 2
        cnt += 1
    print(cnt)




def main():
    n = int(input())
    st = set()
    st.add(2)
    number = 2
    change = 2

    while number <= n:
        change += 3
        number += change
        st.add(number)
    st = sorted(list(st))
    have = 0
    for i in range(len(st) - 1, -1, -1):
        while n >= st[i]:
            n -= st[i]
            have += 1
    print(have)


def __starting_point():
    t = int(input())
    for i in range(t):
        main()
__starting_point()

import math as m
def func(a):
    return int((m.sqrt(24*a+1)-1)//6)

t=int(input())
for _ in range(t):
    n=int(input())
    c=0
    while n>1:
        a=func(n)
        n=n-(3*a*a+a)//2
        c=c+1
    print(c)

A = []
x = 0
i = 1
while x <= 10 ** 11:
    x += 3 * i - 1
    A.append(x)
    i += 1
for i in range(int(input())):
    n = int(input())
    ans = 0
    k = int(n ** 0.5) + 1
    while n >= 0 and k >= 0:
        #print(k)
        if n < A[k]:
            k -= 1
        else:
            n -= A[k]
            ans += 1

    print(ans)

import bisect
seq = [i * (3 * i + 1) // 2 for i in range(30000)]


def solve():
    n = int(input())
    cnt = 0
    while n > 1:
        p = bisect.bisect_left(seq, n + 1) - 1
        n -= seq[p]
        cnt += 1
    return cnt


tests = int(input())
for _ in range(tests):
    print(solve())