Dee Dee went to market to buy some eggs. There are 2 type of egg cartons available in the shop. One type contains 6 eggs and the other type contains 8 eggs. Dee Dee wants to buy exactly N eggs. Calculate the minimal number of egg cartons she must buy.

INPUT

First line of input gives T, the number of test cases.
T lines follow, each having N, the number of eggs.

OUTPUT

Print the minimal number of egg cartons she must buy.
If it's impossible to buy exactly n eggs, print -1.

CONSTRAINTS
1 ≤ T ≤ 50
1 ≤ N ≤ 100

SAMPLE INPUT
2
20
24

SAMPLE OUTPUT
3
3

Explanation

For first case, she should buy 2 cartons containing 6 eggs and 1 carton containing 8 eggs. In total, she buys 3 egg cartons.
For second case, there are two ways to buy 24 eggs: buy 4 cartons containing 6 eggs or buy 3 cartons containing 8 eggs. Minimize the number of cartons.
dp=[0]*102
for i in range(8):
	dp[i]=-1
dp[6]=1
dp[8]=1

for i in range(9,101):
	a=i-8
	b=i-6
	
	if(dp[a]==-1 and dp[b]==-1):
		dp[i]=-1
	elif(dp[a]!=-1 and dp[b]!=-1):
		dp[i]=1+min(dp[a],dp[b])
	else:
		if(dp[a]==-1):
			dp[i]=1+dp[b]
		else:
			dp[i]=1+dp[a]

t=int(raw_input())
while t:
	t-=1
	n=int(raw_input())
	print dp[n]