You are given several queries. In the i-th query you are given a single positive integer n_{i}. You are to represent n_{i} as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.

An integer greater than 1 is composite, if it is not prime, i.e. if it has positive divisors not equal to 1 and the integer itself.


-----Input-----

The first line contains single integer q (1 ≤ q ≤ 10^5) — the number of queries.

q lines follow. The (i + 1)-th line contains single integer n_{i} (1 ≤ n_{i} ≤ 10^9) — the i-th query.


-----Output-----

For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.


-----Examples-----
Input
1
12

Output
3

Input
2
6
8

Output
1
2

Input
3
1
2
3

Output
-1
-1
-1



-----Note-----

12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.

8 = 4 + 4, 6 can't be split into several composite summands.

1, 2, 3 are less than any composite number, so they do not have valid splittings.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Dynamic programming

Mathematics

Greedy algorithms


Solutions:
def max_sum(n):
	if n in [1, 2, 3, 5, 7, 11]:
		return -1
	return n // 4 - n % 2
n = int(input())
[print(max_sum(int(input()))) for i in range(n)]


q = int(input())
for i in range(q):
	n = int(input())
	if n % 2 == 0:
		if n % 4 == 0:
			print(n // 4)
		elif n == 2:
			print(-1)
		else:
			print(1 + (n - 6) // 4)
	elif n < 9:
		print(-1)
	else:
		t = n - 9
		if t % 4 == 0:
			print(1 + t // 4)
		elif t == 2:
			print(-1)
		else:
			print(2 + (t - 6) // 4)


number = int(input())
for i in range(number):
	num = int(input())
	if num != 1 and num != 2 and (num != 3) and (num != 5) and (num != 7) and (num != 11):
		if num % 4 == 0:
			print(num // 4)
		elif num % 4 == 1:
			print((num - 9) // 4 + 1)
		elif num % 4 == 2:
			print((num - 6) // 4 + 1)
		else:
			print((num - 15) // 4 + 2)
	else:
		print('-1')


import sys, math, io, os, time, itertools, collections
mod = 10 ** 9 + 7
sys.setrecursionlimit(10000)
i = sys.stdin.readline
p = sys.stdout.write
global start, end

def isin(l, x):
	left = 0
	right = len(l) - 1
	if x < l[0]:
		return -1
	while left <= right:
		mid = left + (right - left) // 2
		if l[mid] == x:
			return mid
		elif l[mid] < x:
			ans = mid
			left = mid + 1
		else:
			right = mid - 1
	return ans

def ispal(l):
	n = len(l)
	for i in range(n // 2 + 1):
		if l[i] != l[n - i - 1]:
			return False
	return True

def ccarray(l):
	d = {l[k]: k for k in range(len(l))}
	m = sorted(d)
	return [d[m[k]] for k in range(len(l))]

def is_prime(n):
	if n <= 3:
		return n > 1
	if n % 2 == 0 or n % 3 == 0:
		return False
	k = 5
	while k ** 2 <= n:
		if n % k == 0 or n % (k + 2) == 0:
			return False
		k += 6
	return True

def sieve(n):
	prime = [True for k in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for k in range(p * p, n + 1, p):
				prime[k] = False
		p += 1

def main():
	n = int(i())
	if n % 4 == 0:
		p(str(n // 4) + '\n')
	elif n % 4 == 1:
		if n < 9:
			p('-1\n')
		else:
			p(str(1 + (n - 9) // 4) + '\n')
	elif n % 4 == 2:
		if n < 6:
			p('-1\n')
		else:
			p(str(1 + (n - 6) // 4) + '\n')
	elif n < 15:
		p('-1\n')
	else:
		p(str(2 + (n - 15) // 4) + '\n')
t = 1
t = int(i())
start = time.perf_counter()
for _ in range(t):
	main()
end = time.perf_counter()


t = int(input())
s = 0
for _ in range(t):
	a = [1, 2, 3, 5, 7, 11]
	b = [4, 6]
	c = [8, 10]
	n = int(input())
	if n in a:
		print(-1)
	elif n in b:
		print(1)
	elif n in c:
		print(2)
	else:
		if n % 4 == 0:
			s = (n - 12) // 4 + 3
		elif n % 4 == 1:
			s = (n - 13) // 4 + 2
		elif n % 4 == 2:
			s = (n - 14) // 4 + 3
		else:
			s = (n - 15) // 4 + 2
		print(s)


q = [[0, 0], [9, 1], [6, 0], [15, 1]]
for i in range(int(input())):
	a = int(input())
	whole = a // 4
	que = a % 4
	print(-1 if a < q[que][0] else whole - q[que][1])


q = int(input())
for _ in range(q):
	n = int(input())
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
	else:
		rem = n % 4
		if rem == 0:
			print(int(n / 4))
		elif rem == 1:
			print(1 + (n - 9) // 4)
		elif rem == 2:
			print(1 + (n - 6) // 4)
		else:
			print(2 + (n - 6 - 9) // 4)


q = int(input())
for i in range(q):
	n = int(input())
	gg = n // 4
	hh = n % 4
	if hh == 0 and gg > 0:
		print(gg)
	elif hh == 1 and gg > 1:
		print(gg - 1)
	elif hh == 2 and gg > 0:
		print(gg)
	elif hh == 3 and gg > 2:
		print(gg - 1)
	else:
		print(-1)


q = int(input())
for i in range(q):
	n = int(input())
	ans = n // 4
	if n <= 3 or n == 5 or n == 7 or (n == 11):
		print(-1)
	else:
		if n % 2:
			ans -= 1
		print(ans)


a = [-1] * 16
a[0] = 0
for i in range(1, 16):
	for j in [4, 6, 9]:
		if i >= j and a[i - j] != -1:
			a[i] = max(a[i], a[i - j] + 1)
for _ in range(int(input())):
	n = int(input())
	if n < 16:
		print(a[n])
	else:
		t = (n - 16) // 4 + 1
		print(a[n - t * 4] + t)


def kalojadu(n):
	li = [1, 2, 3, 5, 7, 11]
	if n in li:
		return -1
	a = n // 4
	if n % 4 == 0:
		return a
	if n % 4 == 1:
		return a - 1
	if n % 4 == 2:
		return a
	if n % 4 == 3:
		return a - 1
q = int(input())
for i in range(q):
	print(kalojadu(int(input())))


def check(n):
	c = 0
	if n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		c = -1
		n = 0
	elif n < 11 and n != 10 and (n != 8) and (n != 9):
		c += 1
	elif n == 9:
		c += 1
		n -= 9
	else:
		if n > 11 or n == 10 or n == 8:
			c += n // 4 - 1
			n %= 4
			n += 4
		if check(n) > 0:
			c += 1
	return c
n = int(input())
for i in range(n):
	k = int(input())
	k = check(k)
	if k == 0:
		print(-1)
	else:
		print(k)


mod_table = {0: (0, 0), 1: (1, 9), 2: (1, 6), 3: (2, 15)}

def solve(n):
	if n % 4 == 0:
		return n // 4
	else:
		(additional_terms, subtract) = mod_table[n % 4]
		if n < subtract:
			return -1
		else:
			return (n - subtract) // 4 + additional_terms
q = int(input())
for _ in range(q):
	n = int(input())
	print(solve(n))


def main():
	n = int(input())
	arr = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1]
	for i in range(n):
		a = int(input())
		if a >= 12:
			print(a // 4 - a % 2)
		else:
			print(arr[a])

def __starting_point():
	main()
__starting_point()


q = int(input())
for i in range(q):
	n = int(input())
	if n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		print(-1)
	elif n % 2 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(n // 4 - 1)
	else:
		print((n - 15) // 4 + 2)


q = int(input())
for i in range(q):
	a = int(input())
	k = 0
	if a == 11:
		print(-1)
		continue
	if a % 2 == 1:
		if a < 9:
			print(-1)
			continue
		else:
			a -= 9
			k += 1
	k += a // 4
	a %= 4
	if k > 0:
		print(k)
	else:
		print(-1)


def find(n):
	if n % 4 == 0:
		return n // 4
	elif n % 4 == 1:
		if n >= 4 * 2 + 1:
			return n // 4 - 1
		else:
			return -1
	elif n % 4 == 2:
		if n > 2:
			return n // 4
		else:
			return -1
	elif n >= 4 * 3 + 3:
		return n // 4 - 1
	else:
		return -1
for _ in range(int(input())):
	print(find(int(input())))


q = int(input())
for i in range(q):
	n = int(input())
	if n > 3:
		if n % 4 == 0:
			print(n // 4)
		elif (n - 6) % 4 == 0:
			if n - 6 >= 0:
				print((n - 6) // 4 + 1)
			else:
				print('-1')
		elif (n - 9) % 4 == 0:
			if n - 9 >= 0:
				print((n - 9) // 4 + 1)
			else:
				print('-1')
		elif (n - 10) % 4 == 0:
			if n - 10 >= 0:
				print((n - 10) // 4 + 2)
			else:
				print('-1')
		elif (n - 13) % 4 == 0:
			if n - 13 >= 0:
				print((n - 13) // 4 + 2)
			else:
				print('-1')
		elif (n - 15) % 4 == 0:
			if n - 15 >= 0:
				print((n - 15) // 4 + 2)
			else:
				print('-1')
		else:
			print('-1')
	else:
		print('-1')


num = int(input())
for i in range(num):
	n = int(input())
	if n >= 12:
		print(n // 4 - n % 2)
	elif n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		print(-1)
	elif n == 4 or n == 6 or n == 9:
		print(1)
	else:
		print(2)


t = int(input())
while t > 0:
	n = int(input())
	if n < 4:
		print(-1)
	elif n % 4 == 0:
		print(n // 4)
	elif (n - 6) % 4 == 0 and n >= 6:
		print((n - 6) // 4 + 1)
	elif (n - 9) % 4 == 0 and n >= 9:
		print((n - 9) // 4 + 1)
	elif (n - 15) % 4 == 0 and n >= 15:
		print((n - 15) // 4 + 2)
	else:
		print(-1)
	t -= 1


for i in range(int(input())):
	n = int(input())
	if n in (1, 2, 3, 5, 7, 11):
		print(-1)
	elif n % 2:
		print((n - 9) // 4 + 1)
	else:
		print(n // 4)


q = int(input())
a = [int(input()) for i in range(0, q)]

def f(w):
	if w in [1, 2, 3, 5, 7, 11]:
		return -1
	g = 0
	if w % 2 == 1:
		w -= 9
		g = 1
	return w // 4 + g
for i in a:
	print(f(i))


q = int(input())
n = []
for i in range(q):
	n.append(int(input()))
for i in n:
	if i < 4:
		print(-1)
	elif i % 2 == 0:
		print(i // 4)
	elif i % 2 == 1:
		if i < 13 and i != 9:
			print(-1)
		else:
			print((i - 9) // 4 + 1)


q = int(input())
for i in range(q):
	n = int(input())
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
	elif n in [4, 6, 9]:
		print(1)
	else:
		left = n % 4
		if left == 0:
			print(n // 4)
		elif left == 1:
			print(1 + (n - 9) // 4)
		elif left == 2:
			print(1 + (n - 6) // 4)
		else:
			print(2 + (n - 15) // 4)


q = int(input())
for i in range(q):
	a = int(input())
	if a == 1 or a == 2 or a == 3 or (a == 5) or (a == 7) or (a == 11):
		print(-1)
	elif a % 4 == 0:
		print(a // 4)
	elif a % 4 == 1:
		print((a - 9) // 4 + 1)
	elif a % 4 == 2:
		print((a - 6) // 4 + 1)
	else:
		print((a - 6 - 9) // 4 + 2)


n = int(input())
for i in range(n):
	m = int(input())
	x = 0
	if m % 2 == 1:
		m -= 9
		x += 1
	if m < 4 and m != 0:
		print(-1)
	else:
		print(m // 4 + x)


def prime(n):
	if n % 2 == 0:
		return n == 2
	d = 3
	while d * d <= n and n % d != 0:
		d += 2
	return d ** 2 > n
b = True

def parts(n):
	t = n % 4
	if n == 9:
		return 1
	elif n % 4 == 0:
		return n / 4
	elif n % 4 == 1:
		return n // 4 - 1
	elif n % 4 == 2:
		return n // 4
	elif n == 15:
		return 2
	else:
		return n // 4 - 1
A = []
q = int(input())
for i in range(q):
	A.append(int(input()))
for i in A:
	if i in range(1, 4) or i == 11:
		print(-1)
	else:
		tmp = parts(i)
		if tmp <= 0:
			print(-1)
		else:
			print(int(tmp))


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1 and n >= 9:
		print(n // 4 - 1)
	elif n % 4 == 2 and n >= 6:
		print(n // 4)
	elif n % 4 == 3 and n >= 15:
		print(n // 4 - 1)
	else:
		print(-1)


from sys import stdin
input = lambda : stdin.readline()
from math import ceil, sqrt, gcd
l = [4, 6, 9]
for _ in range(int(input())):
	n = int(input())
	count = 0
	if n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		if n < 9:
			print(-1)
		else:
			print(1 + (n - 9) // 4)
	elif n % 4 == 2:
		if n < 6:
			print(-1)
		else:
			print(1 + (n - 6) // 4)
	elif n < 15:
		print(-1)
	else:
		print(2 + (n - 15) // 4)


n = int(input())
while n:
	n -= 1
	num = int(input())
	if num % 4 == 0:
		print(num // 4)
	elif num % 4 == 1:
		print(num // 4 - 2 + 1 if num // 4 - 2 + 1 > 0 else -1)
	elif num % 4 == 2:
		print(num // 4 if num // 4 > 0 else -1)
	elif num % 4 == 3:
		print(num // 4 - 2 + 1 if num // 4 - 2 > 0 else -1)


def f(n):
	if n < 0:
		return -float('inf')
	if n == 0:
		return 0
	if n % 4 == 1:
		return 1 + f(n - 9)
	if n % 4 == 2:
		return 1 + f(n - 6)
	if n % 4 == 3:
		return 2 + f(n - 15)
	return n // 4
q = int(input())
for _ in range(q):
	n = int(input())
	c = f(n)
	if c < 0:
		c = -1
	print(c)


for x in range(int(input())):
	n = int(input())
	k = 0
	if n % 2:
		n -= 9
		k += 1
	if n % 2 == 0 and n % 4 != 0 and (n > 0):
		n = n - 6
		k += 1
	if n % 4 == 0 and n > 0:
		k += n // 4
		n = 0
	if n != 0:
		print(-1)
	else:
		print(k)


def solve(n):
	if n % 4 == 0:
		return n // 4
	elif n % 4 == 1:
		if n < 9:
			return -1
		else:
			n -= 9
			return n // 4 + 1
	elif n % 4 == 2:
		if n < 6:
			return -1
		else:
			n -= 6
			return n // 4 + 1
	elif n < 15:
		return -1
	else:
		n -= 15
		return n // 4 + 2
for _ in range(int(input())):
	print(solve(int(input())))


q = int(input())
for i in range(q):
	a = int(input())
	if a % 2:
		if a == 9:
			print(1)
		elif a - 9 > 2:
			print((a - 9) // 4 + 1)
		else:
			print(-1)
	elif a > 2:
		print(a // 4)
	else:
		print(-1)


n = int(input())
for i in range(n):
	x = int(input())
	ans = 0
	if x < 4:
		print(-1)
	else:
		arr = [0, 1, 0, 1]
		ans = x // 4
		if x % 4 == 1 and ans >= 2:
			ans -= 1
		elif x % 4 == 3 and ans >= 3:
			ans -= 1
		elif not x % 4 in [0, 2]:
			ans = -1
		if ans > 0:
			print(ans)
		else:
			print(-1)


solve = lambda n: -1 if n in {1, 2, 3, 5, 7, 11} else n // 4 - n % 2
[print(solve(int(input()))) for i in range(int(input()))]


for i in range(int(input())):
	a = int(input())
	s = 0
	if a in [1, 2, 3, 5, 7, 11]:
		print(-1)
	else:
		if a % 2 != 0:
			s += 1
			a = a - 9
		if a % 4 != 0:
			s += 1
			a = a - 6
		print(s + a // 4)


import sys
n = int(input())
pr = [1, 2, 3, 5, 7, 11]
for i in range(n):
	k = int(input())
	if k in pr:
		print(-1)
		continue
	if k % 2 == 0:
		print(k // 4)
	else:
		print((k - 9) // 4 + 1)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
INF = float('inf')
mod = 10 ** 9 + 7
set1 = {1, 2, 3, 5, 7, 11}
set2 = {4, 6, 9}
t = INT()
while t != 0:
	n = INT()
	if n in set1:
		print(-1)
	elif n in set2:
		print(1)
	elif n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(1 + (n - 9) // 4)
	elif n % 4 == 2:
		print(1 + (n - 6) // 4)
	else:
		print(2 + (n - 15) // 4)
	t -= 1


q = int(input())
answers = []
for i in range(q):
	number = int(input())
	if number < 4:
		answers.append(-1)
		continue
	if number % 4 == 0:
		answers.append(number // 4)
	elif number % 4 == 1:
		if number < 9:
			answers.append(-1)
		else:
			answers.append(1 + (number - 9) // 4)
	elif number % 4 == 2:
		if number < 6:
			answers.append(-1)
		else:
			answers.append(1 + (number - 6) // 4)
	elif number < 15:
		answers.append(-1)
	else:
		answers.append(2 + (number - 15) // 4)
for i in answers:
	print(i)


n = int(input())
for i in range(n):
	a = int(input())
	if a == 11:
		print(-1)
		continue
	s = a % 4
	k = a // 4
	if s == 0:
		pass
	elif s == 1:
		k -= 1
	elif s == 2:
		pass
	else:
		k -= 1
	if k == 0:
		print(-1)
	else:
		print(k)


a = []
b = int(input())
for i in range(b):
	c = int(input())
	if c % 2 == 0:
		if c / 2 > 1:
			print(int(c / 2 // 2))
		else:
			print(-1)
	elif c == 9:
		print(1)
	elif c - 9 > 2:
		print(int((c - 9) / 2 // 2 + 1))
	else:
		print(-1)


for cnt in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(-1 if n < 9 else 1 + (n - 9) // 4)
	elif n % 4 == 2:
		print(-1 if n < 6 else 1 + (n - 6) // 4)
	else:
		print(-1 if n < 15 else 2 + (n - 15) // 4)


def m(n):
	if n == 9:
		return 1
	elif n < 4:
		return -1
	c = 0
	if n % 2:
		if n >= 13:
			c += 1
			n -= 9
		else:
			return -1
	if not (n - 2) % 4:
		n -= 2
	if not n % 4:
		return c + n // 4

def __starting_point():
	for i in range(int(input())):
		print(m(int(input())))
__starting_point()


n = int(input())
for i in range(n):
	a = int(input())
	if a % 4 == 0:
		print(a // 4)
	elif a % 2 == 1:
		if a < 9:
			print(-1)
		elif a == 9:
			print(1)
		else:
			a = a - 9
			x = a % 4
			k = 3
			while x < a:
				x += 4
				k = 0
				for i in range(2, int(x ** 0.5 + 1)):
					if x % i == 0:
						k = 1
						break
				if k == 1:
					print((a - x) // 4 + 2)
					k = 2
					break
			if x > a or k == 3 or k == 0:
				print(-1)
			elif x == a and k != 2:
				print(2)
	else:
		x = a % 4
		k = 3
		while x < a:
			x += 4
			k = 0
			for i in range(2, int(x ** 0.5 + 1)):
				if x % i == 0:
					k = 1
					break
			if k == 1:
				print((a - x) // 4 + 1)
				k = 2
				break
		if x > a or k == 3 or k == 0:
			print(-1)
		elif x == a and k != 2:
			print(1)


dp = []

def DP(x):
	if x < 0:
		return -10000
	if x == 0:
		return 0
	ret = dp[x]
	if ret != -1:
		return ret
	ret = max(DP(x - 4) + 1, DP(x - 6) + 1, DP(x - 9) + 1, DP(x - 12) + 1)
	dp[x] = ret
	return ret
tt = int(input())
for i in range(0, 24):
	dp.append(-1)
for xx in range(0, tt):
	n = int(input())
	ans = 0
	if n > 20:
		x = n - 20
		ans += int(x / 4)
		n -= ans * 4
	print(max(-1, DP(int(n)) + ans))


maximum = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2, 4]
q = int(input())
for _ in range(q):
	n = int(input())
	base = 12 + n % 4
	if n < len(maximum):
		print(maximum[n])
		continue
	print(maximum[base] + (n - base) // 4)


solve = lambda n: opt[n] if n < 12 else n // 4 - n % 2
opt = [0, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1]
[print(solve(int(input()))) for i in range(int(input()))]


R = lambda : map(int, input().split())
n = int(input())
dp = [0] * 50
dp[4] = dp[6] = dp[9] = 1
dp[8] = 2
for i in range(10, 16):
	dp[i] = max(dp[i - 4] + 1 if dp[i - 4] else 0, dp[i - 6] + 1 if dp[i - 6] else 0, dp[i - 9] if dp[i - 9] + 1 else 0)
for i in range(n):
	x = int(input())
	k = max(0, x - 15 + 3) // 4
	print(k + dp[x - k * 4] if k + dp[x - k * 4] else -1)


n = int(input())
num = []
ans = []
m = n
while m > 0:
	num.append(int(input()))
	m = m - 1
for x in num:
	tmp = x % 4
	div = x // 4
	if tmp == 0:
		ans.append(div)
	elif tmp == 1:
		if div >= 2:
			ans.append(div - 1)
		else:
			ans.append(-1)
	elif tmp == 2:
		if div >= 1:
			ans.append(div)
		else:
			ans.append(-1)
	elif tmp == 3:
		if div >= 3:
			ans.append(div - 1)
		else:
			ans.append(-1)
for x in ans:
	print(x)


fun = lambda num: -1 if num in [1, 2, 3, 5, 7, 11] else num // 4 - num % 2
[print(fun(int(input()))) for i in range(int(input()))]


import sys

def ria():
	return [int(x) for x in input().split()]
q = int(input())
for i in range(q):
	n = int(input())
	if n % 4 == 0:
		print(n // 4)
		continue
	hvar1 = n - 6
	if hvar1 % 4 == 0 and hvar1 >= 0:
		ans = hvar1 // 4 + 1
		print(ans)
		continue
	hvar1 = n - 9
	if hvar1 % 4 == 0 and hvar1 >= 0:
		ans = hvar1 // 4 + 1
		print(ans)
		continue
	hvar1 = n - 15
	if hvar1 % 4 == 0 and hvar1 >= 0:
		ans = hvar1 // 4 + 2
		print(ans)
		continue
	print(-1)


def f(x):
	if x % 4 == 0:
		return x / 4
	else:
		return 1 + (x - 6) / 4
a = int(input())
while a:
	a -= 1
	b = int(input())
	if b == 1 or b == 2 or b == 3 or (b == 5) or (b == 7) or (b == 11):
		print(-1)
	elif b % 2 == 0:
		print(int(f(b)))
	else:
		print(int(f(b - 9) + 1))


a = eval(input())
alist = []
for i in range(a):
	c = eval(input())
	alist.append(c)
for i in alist:
	if i % 2 == 1 or i == 2:
		if i == 1 or 1 == 2 or i == 3 or (i == 5) or (i == 7) or (i == 11):
			print(-1)
		else:
			b = i // 4 - 1
			print(b)
	else:
		b = i // 4
		print(b)


n = int(input())
m = []
for i in range(n):
	m.append(int(input()))
for i in m:
	if i % 2 == 0:
		if i >= 4:
			print(i // 4)
		else:
			print(-1)
	elif i == 9 or i >= 13:
		print((i - 9) // 4 + 1)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	t = -1
	if n % 2 == 0 and n > 2:
		t = n // 4
	elif n > 11 or n == 9:
		t = (n - 9) // 4 + 1
	print(t)


from math import floor

def ehPrimo(n):
	divisivel = 0
	for i in range(1, n + 1):
		if n % i == 0:
			divisivel += 1
		if divisivel > 2:
			return False
	return True
q = int(input())
while q > 0:
	n = int(input())
	if n <= 11:
		if ehPrimo(n):
			print(-1)
			q -= 1
			continue
	if n % 2 == 0:
		print(n // 4)
	else:
		print(n // 4 - 1)
	q -= 1


n = int(input())
todo = [int(input()) for _ in range(n)]
wrong = [1, 2, 3, 5, 7, 11]
for i in todo:
	if i in wrong:
		print(-1)
		continue
	modulo = i % 4
	if modulo == 0 or modulo == 2:
		print(i // 4)
		continue
	elif modulo == 1:
		print((i - 1) // 4 - 1)
		continue
	elif modulo == 3:
		print((i - 3) // 4 - 1)
		continue


import math
H = [0, 0, 0, 0, 1, 0, 1, 0, 2, 1, 2, 0, 3, 2, 3, 2]
q = int(input())
for i in range(q):
	n = int(input())
	if n <= 15:
		if H[n] == 0:
			print(-1)
		else:
			print(H[n])
	else:
		c_4 = math.ceil((n - 15) / 4)
		n -= c_4 * 4
		while n > 0 and H[n] == 0:
			n -= 4
			c_4 += 1
		if n < 0:
			print(-1)
		else:
			print(H[n] + c_4)


r = lambda : int(input())
a = [0, -1]
for i in range(r()):
	x = r()
	if x in [1, 2, 3, 5, 7, 11]:
		print(-1)
	else:
		print(x // 4 + a[x % 2])


for _ in ' ' * int(input()):
	a = int(input())
	if a < 4 or a in [5, 7, 11]:
		print(-1)
	else:
		print(a // 4 - a % 2)


import sys
cache = [0, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2]
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	if n <= 15:
		print(cache[n])
	else:
		t = (n - 16) // 4 + 1
		print(t + cache[n - 4 * t])


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		a = int(input())
		if a <= 3:
			print(-1)
		elif a & 1:
			fors = 0
			if (a - 1) % 4 == 0:
				fors = (a - 1) // 4
			else:
				fors = (a - 1) // 4 - 1
			if fors >= 2:
				print((a - 1) // 4 - 1)
			else:
				print(-1)
		else:
			print(a // 4)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = []
x = 0
y = 0
for i in range(n):
	c = int(input())
	x = c // 4
	y = c % 4
	if c < 13 and c % 2 == 1 and (c % 9 != 0):
		a += [-1]
	elif y == 2 or y == 0:
		if x != 0:
			a += [x]
		else:
			a += [-1]
	elif y == 1 or y == 3:
		if x != 0:
			a += [x - 1]
		else:
			a += [-1]
for i in range(n):
	print(a[i])


t = int(input())
for i in range(t):
	n = int(input())
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
	elif n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print((n - 9) // 4 + 1)
	elif n % 4 == 2:
		print((n - 6) // 4 + 1)
	elif n % 4 == 3:
		print((n - 15) // 4 + 2)


n = int(input())
for i in range(n):
	k = 0
	a = int(input())
	if a % 2 == 1:
		a -= 9
		k += 1
	if a < 4 and a != 0:
		print(-1)
		continue
	k += a // 4
	print(k)


n = int(input())
for i in range(0, n):
	k = int(input())
	num = 0
	if k % 2 == 1:
		k -= 9
		num += 1
	if k % 4 != 0:
		k -= 6
		num += 1
	num += int(k / 4)
	if k < 0 or k % 4 != 0:
		print(-1)
	else:
		print(int(num))


n = int(input())
result = []
for i in range(n):
	entrada = int(input())
	if entrada % 4 == 0:
		result.append(entrada // 4)
	elif entrada % 4 == 1:
		if entrada < 9:
			result.append(-1)
		else:
			result.append((entrada - 9) // 4 + 1)
	elif entrada % 4 == 2:
		if entrada < 6:
			result.append(-1)
		else:
			result.append((entrada - 6) // 4 + 1)
	elif entrada <= 11:
		result.append(-1)
	else:
		result.append((entrada - 9) // 4 + 1)
for r in result:
	print(r)


q = int(input())
k = []
for i in range(q):
	k.append(int(input()))
for n in k:
	if n == 11:
		ans = -1
	elif n % 4 == 0:
		ans = n // 4
	elif n % 4 == 1:
		ans = 1 + (n - 9) // 4
	elif n % 4 == 2:
		ans = 1 + (n - 6) // 4
	else:
		ans = 2 + (n - 15) // 4
	if ans == 0:
		print(-1)
	else:
		print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
		continue
	total = 0
	if n % 2 == 1:
		n -= 9
		total += 1
	total += n // 4
	print(total)


a = int(input())
while a:
	ans = 0
	a -= 1
	b = int(input())
	if b < 4 or b == 5 or b == 7 or (b == 11):
		ans = -1
	else:
		if b % 2:
			b -= 9
			ans += 1
		if b % 4:
			b -= 6
			ans += 1
		ans += b // 4
	print(ans)


q = int(input())
for i in range(q):
	n = int(input())
	if n % 2 == 0:
		if n != 2:
			print(n // 4)
		else:
			print(-1)
	elif n < 9 or n == 11:
		print(-1)
	else:
		print(1 + (n - 9) // 4)


import sys
readline = sys.stdin.readline
Q = int(readline())
Ans = [None] * Q
ans = [None, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2]
for qu in range(Q):
	N = int(readline())
	if N <= 15:
		Ans[qu] = ans[N]
		continue
	if N % 4 == 0:
		Ans[qu] = N // 4
	elif N % 4 == 1:
		Ans[qu] = N // 4 - 1
	elif N % 4 == 2:
		Ans[qu] = N // 4
	else:
		Ans[qu] = N // 4 - 1
print('\n'.join(map(str, Ans)))


for _ in range(int(input())):
	n = int(input())
	if n < 4 or (n == 5 or n == 7 or n == 11):
		print(-1)
		continue
	r = n % 4
	if r == 1:
		print((n - 9) // 4 + 1)
	elif r == 3:
		print((n - 15) // 4 + 2)
	else:
		print(n // 4)


n = int(input())
ans = []
for i in range(n):
	number = int(input())
	if number == 1 or number == 2 or number == 3 or (number == 5) or (number == 7) or (number == 11):
		ans.append(-1)
	else:
		position = number % 4
		if position == 1 or position == 3 or number == 2:
			ans.append(number // 4 - 1)
		elif position == 2:
			ans.append(number // 4)
		else:
			ans.append(number // 4)
for answer in ans:
	print(answer)


t = int(input())
ans = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1]
for _ in range(t):
	n = int(input())
	if n <= 11:
		print(ans[n])
	elif n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(1 + (n - 9) // 4)
	elif n % 4 == 2:
		print(1 + (n - 6) // 4)
	elif n % 4 == 3:
		print(2 + (n - 15) // 4)


n = int(input())
for i in range(n):
	el = int(input())
	if el == 2 or el == 3 or el == 5 or (el == 7) or (el == 11):
		print(-1)
	elif el == 15:
		print(2)
	elif el % 4 == 0:
		print(el // 4)
	elif (el - 6) % 4 == 0:
		print((el - 6) // 4 + 1)
	elif (el - 9) % 4 == 0:
		print((el - 9) // 4 + 1)
	elif (el - 6 - 9) % 4 == 0:
		print((el - 6 - 9) // 4 + 2)
	else:
		print(-1)


a = int(input())
for i in range(a):
	b = int(input())
	if b % 4 == 0:
		print(b // 4)
	elif b % 4 == 2:
		s = 0
		while b > 0:
			if b % 4 == 2:
				s = s + 1
				b = b - 6
			elif b % 4 == 0 and b > 2:
				s = s + b // 4
				b = 0
			else:
				b = -1
		if b == 0:
			print(s)
		else:
			print('-1')
	elif b % 2 == 1:
		if b == 9:
			print('1')
		else:
			b = b - 9
			if b % 4 == 0 and b > 0:
				print(b // 4 + 1)
			elif b % 4 == 2:
				s = 0
				while b > 0:
					if b % 4 == 2:
						s = s + 1
						b = b - 6
					elif b % 4 == 0 and b > 2:
						s = s + b // 4
						b = 0
					else:
						b = -1
				if b == 0:
					print(s + 1)
				else:
					print('-1')
			elif b < 0:
				print('-1')


dp = [-1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2, 4, 3, 4, 3, 5, 4, 5, 4, 6, 5, 6, 5, 7, 6, 7, 6, 8, 7, 8, 7, 9, 8, 9, 8, 10, 9, 10, 9, 11, 10, 11, 10, 12, 11, 12, 11, 13, 12, 13, 12, 14, 13, 14, 13, 15, 14, 15, 14, 16, 15, 16, 15, 17, 16, 17, 16, 18, 17, 18, 17, 19, 18, 19, 18, 20, 19, 20, 19, 21, 20, 21, 20, 22, 21, 22, 21, 23, 22, 23, 22, 24, 23, 24, 23]

def main():
	n = int(input())
	if n < len(dp):
		print(dp[n - 1])
		return
	res = (n - len(dp)) // 4
	n -= (n - len(dp)) // 4 * 4
	while n >= len(dp):
		n -= 4
		res += 1
	res += dp[n - 1]
	print(res)
	return
q = int(input())
for i in range(q):
	main()


n = int(input())
for i in range(n):
	z = int(input())
	if z in range(1, 12):
		if z in (8, 10):
			ans = 2
		elif z in (1, 2, 3, 5, 7, 11):
			ans = -1
		else:
			ans = 1
	else:
		ans = z // 4 - z % 2
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	x = n % 4
	answer = -1
	if x == 0:
		answer = n // 4
	elif x == 1:
		if n >= 9:
			answer = n // 4 - 1
	elif x == 2:
		if n >= 6:
			answer = n // 4
	elif n >= 15:
		answer = n // 4 - 1
	if answer <= 0:
		print(-1)
	else:
		print(answer)


n = int(input())
for i in range(n):
	a = int(input())
	if a % 4 == 0:
		print(a // 4)
	elif a - 6 >= 0 and (a - 6) % 4 == 0:
		print((a - 6) // 4 + 1)
	elif a - 9 >= 0 and (a - 9) % 4 == 0:
		print((a - 9) // 4 + 1)
	elif a - 15 >= 0 and (a - 15) % 4 == 0:
		print((a - 15) // 4 + 2)
	else:
		print(-1)


dp = {0: 4, 2: 6, 1: 9, 3: 15}
sum = {0: 1, 2: 1, 1: 1, 3: 2}

def solve(x):
	if x in [4, 6, 9]:
		return 1
	if x == 15:
		return 2
	tmp = dp[x % 4]
	if tmp >= x:
		return -1
	return sum[x % 4] + (x - tmp) // 4
for _ in range(int(input())):
	print(solve(int(input())))


easy = [1, 2, 3, 5, 7, 11]

def cheker(i):
	if i in easy:
		print(-1)
	elif i % 2 == 0 and i % 4 != 0:
		if i == 6:
			print(1)
		else:
			print(1 + (i - 6) // 4)
	elif i % 4 == 0:
		print(i // 4)
	elif (i - 1) % 4 == 0:
		if i == 9:
			print(1)
		else:
			print(1 + (i - 9) // 4)
	elif (i + 1) % 4 == 0:
		print((i - 9 - 6) // 4 + 2)
l = int(input())
for i in range(l):
	now = int(input())
	cheker(now)


for i in range(int(input())):
	n = int(input())
	arr = [1, 2, 3, 5, 7, 11]
	if n in arr:
		print(-1)
	else:
		y = n // 4
		if n & 1:
			y -= 1
		print(y)


q = int(input())
for _ in range(q):
	n = int(input())
	if n < 4:
		print(-1)
		continue
	if n in [5, 7, 11]:
		print(-1)
		continue
	if n % 2 == 0:
		ans = 0
		if n % 4 != 0:
			n -= 6
			ans += 1
		ans += n // 4
		print(ans)
	else:
		ans = 1
		n -= 9
		ans += n // 4
		print(ans)


from math import ceil
n = int(input())
ans = [-1] * 17
ans[0] = 0
for i in range(1, 17):
	for j in [4, 6, 9]:
		if i >= j and ans[i - j] != -1:
			ans[i] = max(ans[i - j] + 1, ans[i])
for i in range(n):
	x = int(input())
	if x < 16:
		print(ans[x])
	else:
		t = ceil((x - 16) // 4) + 1
		print(t + ans[x - 4 * t])


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def isprime(n):
	if n == 1:
		return 0
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return 0
	return 1
for i in range(ii()):
	n = ii()
	if n % 4 == 0 and n > 0:
		print(n // 4)
	elif n % 4 == 2 and n > 2:
		print(n // 4)
	elif n % 4 == 3 and n >= 15:
		print(n // 4 - 1)
	elif n % 4 == 1 and n >= 9:
		print(n // 4 - 1)
	else:
		print('-1')


for _ in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		print(n // 4 if n >= 4 else -1)
	elif n == 9:
		print(1)
	else:
		print((n - 9) // 4 + 1 if n >= 13 else -1)


for _ in range(int(input())):
	n = int(input())
	if n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		print(-1)
	elif n % 2 == 0:
		print(n // 4)
	else:
		print(n // 4 - 1)


def check(n):
	if n < 4:
		return -1
	c = n // 4
	r = n % 4
	if r == 0 or r == 2:
		return c
	if r == 1:
		if c < 2:
			return -1
		else:
			return c - 1
	if r == 3:
		if c < 3:
			return -1
		else:
			return c - 1
q = int(input())
answer = []
while q > 0:
	q -= 1
	answer.append(str(check(int(input()))))
print('\n'.join(answer))


n = int(input())
for i in range(n):
	a = int(input())
	s = 0
	if a >= 12 or a == 8 or a == 10:
		if a % 2 == 1:
			a -= 9
			s += 1
		if a % 4 == 2:
			a -= 6
			s += 1
		s += a // 4
	elif a < 4 or a == 5 or a == 7 or (a == 11):
		s = -1
	elif a == 4 or a == 6 or a == 9:
		s = 1
	print(s)


q = int(input())
for i in range(q):
	a = int(input())
	if a % 2 == 0:
		if a == 2:
			print(-1)
		else:
			print(a // 4)
	elif a == 11:
		print(-1)
	elif a % 2 != 0 and a >= 9:
		print((a - 9) // 4 + 1)
	else:
		print(-1)


from math import trunc
n = int(input())
for _ in range(n):
	a = int(input())
	if a >= 12:
		if trunc(a / 4) - a % 2 != 0:
			print(trunc(a / 4) - a % 2)
		else:
			print(-1)
	elif a == 1 or a == 2 or a == 3 or (a == 5) or (a == 7) or (a == 11):
		print(-1)
	elif a == 4 or a == 6 or a == 9:
		print(1)
	else:
		print(2)


q = int(input())
for _ in range(q):
	num = int(input())
	if num < 4:
		print(-1)
	elif num % 4 == 1:
		ans = num // 4 - 1
		if ans > 0 and ((ans - 1) * 4 + 9 == num or (ans - 1) * 4 + 15 == num):
			print(ans)
		else:
			print(-1)
	elif num % 4 == 3:
		ans = num // 4 - 1
		if ans - 2 >= 0 and (ans - 2) * 4 + 6 + 9 == num:
			print(ans)
		else:
			print(-1)
	else:
		ans = num // 4
		print(ans)


def prime(n):
	if n == 1:
		return False
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
for _ in range(int(input())):
	n = int(input())
	if n < 4:
		print(-1)
	elif n % 4 == 2 or n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		if n >= 8:
			print(n // 4 - 1)
		else:
			print(-1)
	elif n >= 15:
		print(n // 4 - 1)
	else:
		print(-1)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	if n in [1, 2, 3, 5, 7, 11]:
		pr(-1)
	else:
		pr(n // 4 - n % 2)
for _ in range(inp()):
	solve()


q = int(input())
a = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1]
for i in range(q):
	n = int(input())
	if n <= 11:
		print(a[n])
	else:
		ans = n // 4
		if n % 2 == 1:
			ans -= 1
		print(ans)


n = int(input())
for i in range(n):
	p = int(input())
	if p in [1, 2, 3, 5, 7, 11]:
		print(-1)
	elif p % 4 == 0 or p % 4 == 2:
		print(p // 4)
	elif p % 4 == 1 or p % 4 == 3:
		print(p // 4 - 1)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	print(-1 if n in [1, 2, 3, 5, 7, 11] else n // 4 - (n & 1))


e = [1, 2, 3, 5, 7, 11]
q = int(input())
for i in range(q):
	n = int(input())
	if n in e:
		print(-1)
	elif n == 15:
		print(2)
	elif n == 19:
		print(3)
	elif n == 23:
		print(4)
	elif n % 4 == 0:
		print(n // 4)
	elif n % 4 == 2:
		print(n // 4)
	else:
		print(n // 4 - 1)


for i in range(int(input())):
	num = int(input())
	print(-1 if num in [1, 2, 3, 5, 7, 11] else (num >> 2) - (num & 1))


from sys import stdin as read
from sys import stdout as out
n = int(read.readline())
res = ''
for i in range(n):
	x = int(read.readline())
	if x % 2 != 0:
		z = (x - 9) // 4
		if x == 1 or x == 3 or x == 5 or (x == 7) or (x == 11):
			out.write('-1\n')
		else:
			out.write(str(z + 1) + '\n')
	else:
		z = x // 4
		if x < 4:
			out.write('-1\n')
		else:
			out.write(str(z) + '\n')


q = int(input())
for _ in range(q):
	n = int(input())
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
	elif n in [4, 6, 9]:
		print(1)
	else:
		k4 = n // 4
		ost4 = n % 4
		ans4 = -1
		if ost4 == 0:
			ans4 = k4
		elif ost4 == 1:
			if k4 >= 2:
				ans4 = k4 - 1
		elif ost4 == 2:
			ans4 = k4
		elif k4 >= 3:
			ans4 = k4 - 1
		print(ans4)


for _ in range(int(input())):
	k = int(input())
	if k == 4 or k == 6 or k == 9:
		print(1)
	elif k == 1 or k == 2 or k == 3 or (k == 5) or (k == 7) or (k == 11):
		print(-1)
	else:
		comp = [4, 6, 9]
		if k % comp[0] == 0:
			print(k // comp[0])
		elif (k - comp[1]) % comp[0] == 0:
			print((k - comp[1]) // comp[0] + 1)
		elif (k - comp[2]) % comp[0] == 0:
			print((k - comp[2]) // comp[0] + 1)
		elif (k - comp[2] - comp[1]) % comp[0] == 0:
			print((k - comp[2] - comp[1]) // comp[0] + 2)
		elif k % comp[1] == 0:
			print(k // comp[1])
		elif (k - comp[2]) % comp[1] == 0:
			print((k - comp[2]) // comp[1] + 1)
		else:
			print(k // comp[2])


def f(a):
	if a % 4 == 0:
		return a // 4
	elif a % 2 == 0 and a >= 6:
		return (a - 6) // 4 + 1
	elif a >= 9:
		ans = f(a - 9) + 1
		if ans == 0:
			return -1
		return ans
	return -1
q = int(input())
for i in range(q):
	print(f(int(input())))


n = int(input())
answer = []
for _ in range(n):
	i = int(input())
	if i < 4:
		answer.append(str(-1))
		continue
	v = 4
	counter = i // 4
	i = i % 4
	if i == 0 or i == 2:
		answer.append(str(counter))
	elif i == 1:
		if counter > 1:
			answer.append(str(counter - 1))
		else:
			answer.append(str(-1))
	elif i == 3:
		if counter >= 3:
			answer.append(str(counter - 1))
		else:
			answer.append(str(-1))
print('\n'.join(answer))


import math

def function(n):
	if n <= 3:
		return -1
	if n >= 4:
		if n % 4 == 0:
			return int(n / 4)
		if n % 4 != 0:
			if n % 2 == 0:
				return math.floor(n / 4)
			if n % 2 != 0:
				if n == 9:
					return 1
				if n < 9:
					return -1
				total = 1
				n -= 9
				if n <= 3:
					return -1
				return 1 + math.floor(n / 4)
q = int(input())
for k1 in range(q):
	n = int(input())
	print(function(n))


mas = [-1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1]
for i in range(int(input())):
	a = int(input())
	if a > 11:
		cel = a // 4
		ost = a % 4
		if ost == 1:
			cel -= 1
		elif ost == 3:
			cel -= 1
		print(cel)
	else:
		print(mas[a - 1])


from sys import stdin as fin
q = int(fin.readline())
denied = {1, 2, 3, 5, 7, 11}
for i in range(q):
	n = int(fin.readline())
	if n in denied:
		print(-1)
		continue
	(c4, m4) = divmod(n, 4)
	if m4 == 1 or m4 == 3:
		print(c4 - 1)
	else:
		print(c4)


q = int(input())
while q > 0:
	n = int(input())
	add = 0
	if n % 2 == 1:
		n -= 9
		add += 1
	if n < 4 and n != 0:
		print(-1)
	else:
		print(n // 4 + add)
	q -= 1


q = int(input())
while q:
	n = int(input())
	if n == 4:
		print(1)
	elif n == 6:
		print(1)
	elif n == 8:
		print(2)
	elif n == 9:
		print(1)
	elif n == 10:
		print(2)
	elif n == 12:
		print(3)
	elif n == 13:
		print(2)
	elif n == 14:
		print(3)
	elif n < 14:
		print(-1)
	elif n % 2 == 0:
		if n % 4 == 0:
			print(n // 4)
		else:
			print((n - 6) // 4 + 1)
	else:
		n -= 9
		if n % 4 == 0:
			print(n // 4 + 1)
		else:
			print((n - 6) // 4 + 1 + 1)
	q -= 1


n = int(input())
a = [0, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3]
b = [3, 2, 3, 2, 4, 3, 4, 3, 5, 4, 5, 4]
for i in range(n):
	x = int(input())
	if x <= 12:
		print(a[x])
	else:
		print((x - 12) // 12 * 3 + b[x % 12])


for _ in range(int(input())):
	n = int(input())
	(d, y) = divmod(n, 4)
	if y == 0:
		print(d)
	elif y == 1:
		if d > 1:
			print(d - 1)
		else:
			print(-1)
	elif y == 2:
		if d:
			print(d)
		else:
			print(-1)
	elif y == 3:
		if d > 2:
			print(d - 1)
		else:
			print(-1)


def splitting(x):
	if x % 2 == 1:
		if x <= 7 or x == 11:
			return -1
		return splitting(x - 9) + 1
	else:
		if x == 2:
			return -1
		return x // 4
q = int(input())
for i in range(q):
	print(splitting(int(input())))


n = int(input())
for i in range(n):
	ch = int(input())
	if ch <= 3:
		print(-1)
	else:
		sum = ch // 4
		ch = ch % 4
		if ch == 0 or ch == 2:
			print(sum)
		elif ch == 1:
			if sum >= 2:
				print(sum - 1)
			else:
				print(-1)
		elif ch == 3:
			if sum >= 3:
				print(sum - 1)
			else:
				print(-1)


while True:
	try:
		t = input()
		t = int(t)
		while t != 0:
			t -= 1
			n = input()
			n = int(n)
			ans = int(0)
			if n % 4 == 0 or n % 4 == 2:
				ans = int(n / 4)
			else:
				n -= 9
				ans = int(n / 4 + 1)
			if n < 4 and n:
				ans = -1
			print(ans)
	except:
		break


n = int(input())
i = 0
while i < n:
	a = int(input())
	if (a - 9) % 4 == 0 and a >= 9:
		print(1 + (a - 9) // 4)
	elif (a - 6) % 4 == 0 and a >= 6:
		print(1 + (a - 6) // 4)
	elif (a - 15) % 4 == 0 and a >= 15:
		print(2 + (a - 15) // 4)
	elif a % 4 == 0:
		print(a // 4)
	else:
		print(-1)
	i += 1


I = lambda : int(input())
for _ in range(I()):
	(a, b) = divmod(I(), 4)
	if b < 1:
		print(a)
	elif b < 2:
		print(a - 1 - (a == 1))
	elif b < 3:
		print(a - (a == 0))
	else:
		print(a * (a > 2) - 1)


lis = [0, 1, 2, 3, 5, 7, 11]
for _ in range(int(input())):
	n = int(input())
	if n in lis:
		print(-1)
	elif n % 2 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(1 + (n - 9) // 4)
	elif n % 4 == 3:
		print((n - 7) // 4)


n = int(input())
e = []

def tir(n):
	if n in [1, 2, 3, 5, 7, 11]:
		return -1
	elif n % 2 == 0:
		return int(n // 4)
	else:
		return int(n // 4) - 1
for i in range(n):
	r = int(input())
	e.append(tir(r))
for i in e:
	print(i)


q = int(input())
for i in range(q):
	num = int(input())
	if num <= 3 or num == 5 or num == 7 or (num == 11):
		print(-1)
	else:
		tnum = num // 4
		if num % 2 == 1:
			print(tnum - 1)
		else:
			print(tnum)


q = int(input())
for i in range(q):
	n = int(input())
	os = n % 4
	ce = n // 4
	if n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		print(-1)
	elif os == 0 or os == 2:
		print(ce)
	elif os == 1 or os == 3:
		print(ce - 1)


q = int(input())
no = [1, 2, 3, 5, 7, 11]
for i in range(q):
	n = int(input())
	if n in no:
		print(-1)
		continue
	if n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print((n - 9) // 4 + 1)
	elif n % 4 == 2:
		print((n - 6) // 4 + 1)
	elif n % 4 == 3:
		print((n - 15) // 4 + 2)


q = int(input())
b = []
for i in range(q):
	a = int(input())
	ost = a % 4
	if ost == 0:
		b.append(a // 4)
	elif ost == 2 and a != 2:
		b.append(a // 4)
	elif ost == 1 and a != 1:
		b.append(a // 4 - 1)
	elif ost == 3 and a != 3 and (a >= 15):
		b.append(a // 4 - 1)
	else:
		b.append(-1)
for e in b:
	if e == 0:
		print(-1)
	else:
		print(e)


q = int(input())
U = 200
primes = [2, 3]
for i in range(5, U + 1, 2):
	if all((i % x != 0 for x in primes)):
		primes.append(i)
dp = [-1, -1, -1, -1, 1]
for i in range(5, U + 1):
	val = max(dp[i - 4], dp[i - 6 if i >= 6 else 0], dp[i - 9 if i >= 9 else 0])
	dp.append(max(1 if i not in primes else -1, val + 1 if val > 0 else -1))
for i in range(q):
	n = int(input())
	if n > U:
		c = 1
		while True:
			ans = (n - U) // 4 + c
			N = n - 4 * ans
			c += 1
			if dp[N] > 0:
				break
			if c >= U - 1:
				break
	else:
		ans = 0
	print(ans + dp[n - 4 * ans] if dp[n - 4 * ans] != 0 else -1)


q = int(input())
answer = []
for i in range(q):
	n = int(input())
	if n == 1 or n == 2 or n == 3 or (n == 5) or (n == 7) or (n == 11):
		answer.append(-1)
	else:
		if n % 4 == 0 or n % 4 == 2:
			answer.append(n // 4)
		if n % 4 == 1 or n % 4 == 3:
			answer.append(n // 4 - 1)
print(*answer, sep='\n')


for _ in range(int(input())):
	k = int(input())
	if k == 4 or k == 6 or k == 9:
		print(1)
	elif k == 1 or k == 2 or k == 3 or (k == 5) or (k == 7) or (k == 11):
		print(-1)
	elif k == 15:
		print(2)
	elif k == 19:
		print(3)
	elif k == 23:
		print(4)
	elif k % 2 == 0:
		print(k // 4)
	else:
		print(k // 4 - 1)


maxn = 16
ans = [-1] * maxn
ans[0] = 0
arr = [4, 6, 9]
for i in range(1, maxn):
	for j in arr:
		if i >= j and ans[i - j] != -1:
			ans[i] = max(ans[i], ans[i - j] + 1)
q = int(input())
while q:
	n = int(input())
	if n < maxn:
		print(ans[n])
	else:
		t = (n - maxn) // 4 + 1
		print(t + ans[n - 4 * t])
	q -= 1


from math import floor
q = int(input())
n = [int(input()) for i in range(0, q)]
for k in n:
	x = floor(k / 4) - k % 2
	if x > 0 and k != 11:
		print(x)
	else:
		print(-1)


def f(n):
	if n % 4 == 0:
		return n // 4
	else:
		return (n - 6) // 4 + 1

def process(n):
	if n <= 3:
		return -1
	elif n % 2 and n < 13 and (n != 9):
		return -1
	elif n % 2:
		return f(n - 9) + 1
	else:
		return f(n)
n = int(input())
for i in range(n):
	print(process(int(input())))


q = int(input())
for _ in range(q):
	n = int(input())
	f = n // 4
	r = n % 4
	if f:
		if r == 2 or r == 0:
			print(f)
		elif r == 1 and f >= 2:
			print(f - 1)
		elif r == 3 and f >= 3:
			print(f - 1)
		else:
			print(-1)
	else:
		print(-1)


q = int(input())
for i in range(q):
	n = int(input())
	ans = n // 4
	if n % 4 == 1:
		ans -= 1
	elif n % 4 == 3:
		if ans > 2:
			ans -= 1
		else:
			ans = 0
	if ans <= 0:
		ans = -1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	if n == 4:
		print(1)
		continue
	if n <= 3 or n == 5 or n == 7 or (n == 11):
		print(-1)
		continue
	if n & 1:
		n = n - 9
		cnt = 1
		if n % 4 == 0:
			cnt += n // 4
		elif n >= 6:
			cnt += 1
			n = n - 6
			cnt += n // 4
		else:
			print(-1)
			continue
		print(cnt)
	else:
		if n % 4 == 0:
			cnt = n // 4
		elif n >= 6:
			n = n - 6
			cnt = 1
			cnt += n // 4
		else:
			print(-1)
			exit()
		print(cnt)


from math import sqrt

def readInts():
	return map(int, input().split())
limit = 1000
isPrime = [True] * (limit + 1)
isPrime[0] = isPrime[1] = False
for i in range(int(sqrt(limit) + 1)):
	if isPrime[i]:
		for j in range(i * i, limit, i):
			isPrime[j] = False
dpSz = 200
dp = [-(dpSz - 1)] * dpSz
dp[0] = 0
for i in range(2, dpSz):
	if not isPrime[i]:
		for j in range(0, dpSz - i):
			dp[i + j] = max(dp[j] + 1, dp[i + j])
for i in range(len(dp)):
	if dp[i] < 0:
		dp[i] = -1
nQueries = int(input())
for _ in range(nQueries):
	n = int(input())
	ans = 0
	if n >= dpSz:
		ans += (n - dpSz + 1 + 3) // 4
		n -= ans * 4
	if dp[n] == -1:
		print(-1)
	else:
		print(ans + dp[n])


q = int(input())
answer = list()
values = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
for i in range(4, len(values)):
	for n in [4, 6, 9]:
		if i >= n and values[i - n] != -1:
			values[i] = max(values[i], values[i - n] + 1)
while q > 0:
	n = int(input())
	if n < 16:
		answer.append(values[n])
	else:
		aux = int((n - 16) / 4 + 1)
		answer.append(aux + values[n - aux * 4])
	q -= 1
for a in answer:
	print(a)


def clev(x):
	if x % 4 == 0:
		return x // 4
	elif x % 4 == 1:
		return x // 4 - 1
	elif x % 4 == 2:
		return x // 4
	else:
		return x // 4 - 1
res = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2, 4, 3, 4, 3, 5]
q = int(input())
for i in range(q):
	n = int(input())
	if n > 20:
		print(clev(n))
	else:
		print(res[n])


for _ in range(int(input())):
	ni = int(input())
	if ni % 2 == 0:
		print(-1) if ni == 2 else print(ni // 4)
	else:
		print(-1) if ni < 9 or ni == 11 else print((ni - 9) // 4 + 1)


[print(([-1] * 4 + [1, -1, 1, -1, 2, 1, 2, -1])[n]) if n < 12 else print(n // 4 if n % 2 == 0 else n // 4 - 1) for n in [int(input()) for _ in range(int(input()))]]


q = int(input())
for i in range(q):
	a = int(input())
	c = 0
	if a % 2:
		a -= 9
		c += 1
	if a < 0:
		print(-1)
		continue
	if a % 4:
		a -= 6
		c += 1
	if a < 0:
		print(-1)
		continue
	c += a // 4
	print(c)


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	n = int(input())
	if n < 4 or n == 5 or n == 7:
		print('-1')
	else:
		count = n // 4
		rest = n % 4
		if rest == 0 or rest == 2:
			print(count)
		elif rest == 1:
			print(count - 1)
		elif n > 11:
			print(count - 1)
		else:
			print('-1')


from sys import stdin
z = [-1] * 16
z[0] = 0
ans = ''
for i in range(16):
	for j in [4, 6, 9]:
		if i - j >= 0 and z[i - j] != -1:
			z[i] = max(z[i], z[i - j] + 1)
for _ in ' ' * int(stdin.readline()):
	a = int(stdin.readline())
	if a < 16:
		print(z[a])
	else:
		k = (a - 12) // 4
		print(k + z[a - 4 * k])


n = int(input())
lst = []
for i in range(n):
	j = int(input())
	k = j // 4
	a = j % 4
	if a == 1:
		c = k - 1
	elif a == 3:
		c = k - 1
	else:
		c = k
	if c == 0:
		lst.append(-1)
	else:
		lst.append(c)
	if j == 11:
		lst[i] = -1
for i in range(n):
	print(lst[i])


q = int(input())
for x in range(q):
	n = int(input())
	ans = 0
	if n & 1:
		n -= 9
		ans += 1
		if n >= 4 or n == 0:
			print(ans + n // 4)
		else:
			print(-1)
	elif n == 2:
		print(-1)
	else:
		print(n // 4)


n = int(input())
for i in range(n):
	z = int(input())
	if z < 12 and z != 4 and (z != 6) and (z != 8) and (z != 9) and (z != 10):
		print(-1)
	elif z == 8 or z == 10:
		print(2)
	elif z == 4 or z == 6 or z == 9:
		print(1)
	else:
		print(z // 4 - z % 2)


n = int(input())
ans = ''
for i in range(n):
	a = int(input())
	if a % 2 != 0:
		b = (a - 9) // 4
		if a == 1 or a == 3 or a == 5 or (a == 7) or (a == 11):
			ans += '-1\n'
		else:
			ans += str(b + 1) + '\n'
	else:
		b = a // 4
		if a < 4:
			ans += '-1\n'
		else:
			ans += str(b) + '\n'
print(ans[:-1])


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			if n in [1, 2, 3, 5, 7, 11]:
				ans.append('-1')
			elif not n % 2:
				if not n % 4:
					ans.append(str(n // 4))
				else:
					ans.append(str(1 + (n - 6) // 4))
			else:
				n -= 9
				if not n % 4:
					ans.append(str(1 + n // 4))
				else:
					ans.append(str(2 + (n - 6) // 4))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
threading.Thread(target=main).start()


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
for i in range(n):
	if a[i] > 11:
		if (a[i] - 9) % 4 == 0:
			print((a[i] - 9) // 4 + 1)
		elif (a[i] - 6) % 4 == 0:
			print((a[i] - 6) // 4 + 1)
		elif (a[i] - 9 - 6) % 4 == 0:
			print((a[i] - 9 - 6) // 4 + 2)
		else:
			print(a[i] // 4)
	elif a[i] == 11 or a[i] == 7 or a[i] == 5 or (a[i] < 4):
		print(-1)
	elif a[i] == 9 or a[i] == 6 or a[i] == 4:
		print(1)
	else:
		print(2)


q = int(input())
h = {4: 1, 6: 1, 9: 1}
for w in range(q):
	n = int(input())
	if n < 8:
		if n not in h:
			print(-1)
		else:
			print(1)
	else:
		c = 0
		if n % 2 != 0:
			n -= 9
			c += 1
			if n < 4 and n != 0:
				print(-1)
			else:
				c += n // 4
				print(c)
		else:
			c += n // 4
			print(c)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def precompute():
	dp = [-1 for _ in range(16)]
	dp[0] = 0
	composite = [4, 6, 9]
	for i in range(1, 16):
		for j in composite:
			if i >= j and dp[i - j] != -1:
				dp[i] = max(dp[i], 1 + dp[i - j])
	return dp

def main():
	dp = precompute()
	for tc in range(int(input())):
		n = int(input())
		if n < 16:
			print(dp[n])
		else:
			t = (n - 16) // 4 + 1
			print(t + dp[n - 4 * t])
main()


for _ in range(int(input())):
	n = int(input())
	if n < 4:
		print(-1)
	elif n % 2 == 0:
		print(n // 4)
	elif n % 4 == 1:
		if n < 9:
			print(-1)
		else:
			print((n - 5) // 4)
	elif n < 15:
		print(-1)
	else:
		print((n - 7) // 4)


from sys import stdin
rInt = lambda : int(stdin.readline().strip('\n'))
rIntArray = lambda : [int(x) for x in stdin.readline().split()]
rString = lambda : stdin.readline().strip('\n')
rStrArray = lambda : [x for x in stdin.readline().split()]
for _ in range(rInt()):
	n = rInt()
	if n in [1, 2, 3, 5, 7, 11]:
		print(-1)
	elif n % 4 == 0:
		print(n // 4)
	elif n % 4 == 1:
		print(n // 4 - 1)
	elif n % 4 == 2:
		print(n // 4)
	elif n % 4 == 3:
		print(n // 4 - 1)


from math import sqrt, ceil, floor

def getDividers(n):
	result = []
	for i in range(2, n):
		if n % i == 0:
			if result == []:
				if n % (i * i) == 0:
					return i * i
				else:
					result.append(i)
			else:
				return i * result[0]
	return 0
n = int(input())
ans = []
for i in range(n):
	inp = int(input())
	if inp > 12:
		ans.append(floor(inp / 4) - inp % 2)
	elif inp == 10:
		ans.append(2)
	else:
		divs = getDividers(inp)
		if divs == 0:
			ans.append(-1)
		else:
			ans.append(inp // divs)
for i in range(n):
	print(ans[i])


def solve(x):
	if x % 4 == 0:
		return x // 4
	divisors = [6, 9]
	ans = -1
	for d1 in divisors:
		if x - d1 >= 0 and (x - d1) % 4 == 0:
			ans = max(ans, (x - d1) // 4 + 1)
		for d2 in divisors:
			if d1 != d2 and x - d1 - d2 >= 0 and ((x - d1 - d2) % 4 == 0):
				ans = max(ans, (x - d1 - d2) // 4 + 2)
	return ans
q = int(input())
for _ in range(q):
	n = int(input())
	print(solve(n))


q = int(input())
inputs = [0] * q
for i in range(q):
	inputs[i] = int(input())
MAX_N = 16
a = [-1] * (MAX_N + 1)
a[0] = 0
for i in range(4, MAX_N):
	for j in [4, 6, 9]:
		if i >= j and a[i - j] >= 0:
			a[i] = max(a[i], a[i - j] + 1)
for n in inputs:
	if n < MAX_N:
		print(a[n])
	else:
		k = (n - MAX_N) // 4 + 1
		print(a[n - 4 * k] + k)


number = int(input())
for i in range(number):
	a = int(input())
	if a == 1 or a == 2 or a == 3:
		print(-1)
		continue
	if a % 4 == 0:
		print(a // 4)
		continue
	elif a % 4 == 1:
		if a > 9:
			print(a // 4 - 1)
			continue
		if a == 9:
			print(1)
			continue
		else:
			print(-1)
			continue
	elif a % 4 == 2:
		if a > 6:
			print(a // 4)
			continue
		if a == 6:
			print(1)
			continue
		else:
			print(-1)
			continue
	elif a > 15:
		print(a // 4 - 1)
		continue
	elif a == 15:
		print(2)
		continue
	else:
		print(-1)
		continue


count = int(input())
results = []
for i in range(count):
	num = int(input())
	if num == 11:
		n = -1
	else:
		n = num // 4 + {0: 0, 1: -1, 2: 0, 3: -1}[num % 4]
		if n <= 0:
			n = -1
	results.append(n)
print('\n'.join([str(i) for i in results]))


queries = []
for i in range(int(input())):
	queries.append(int(input()))
primos = [1, 2, 3, 5, 7, 11, 13]
trazas_menor_15 = []
for i in range(15):
	try:
		primos.index(i + 1)
		if i + 1 != 13:
			trazas_menor_15.append(-1)
		else:
			raise Exception()
	except:
		trazas_menor_15.append(1)
		for j in range(i + 1):
			try:
				primos.index(j + 1)
			except:
				if i - j > 0:
					trazas_menor_15[i] = max(trazas_menor_15[i], trazas_menor_15[i - j - 1] + 1)
for i in queries:
	if i > 15:
		print(-(-(i - 15) // 4) + trazas_menor_15[i - 4 * -(-(i - 15) // 4) - 1])
	else:
		print(trazas_menor_15[i - 1])


from math import sqrt, pow, ceil
from decimal import *
l1 = int(input())
resp = 100001 * [0]
for i in range(l1):
	n = int(input())
	if n % 4 == 0:
		print(int(n / 4))
	elif n % 4 == 1:
		if n < 9:
			print('-1')
		else:
			print(int((n - 9) / 4 + 1))
	elif n % 4 == 2:
		if n < 6:
			print('-1')
		else:
			print(int((n - 6) / 4 + 1))
	elif n <= 11:
		print('-1')
	else:
		print(int((n - 9) / 4 + 1))


q = int(input())
b = []
for i in range(q):
	a = int(input())
	if a % 4 == 0:
		b.append(a // 4)
	else:
		kek = a % 4
		if kek == 2 and a != 2:
			b.append(a // 4)
		elif kek == 1 and a != 1:
			b.append(a // 4 - 1)
		elif kek == 3 and a != 3 and (a >= 15):
			b.append(a // 4 - 1)
		else:
			b.append(-1)
for elem in b:
	if elem == 0:
		print(-1)
	else:
		print(elem)


import math
from math import log2, sqrt
from bisect import bisect_left, bisect_right
import bisect
import sys
from sys import stdin, stdout
import os
sys.setrecursionlimit(pow(10, 6))
import collections
from collections import defaultdict
from statistics import median
from queue import Queue
inf = float('inf')
maxa = pow(10, 5)
prime = [True for i in range(maxa + 1)]

def sieve(n=maxa):
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
sieve(maxa)
composite = []
least = 1000
for i in range(2, least + 1):
	if not prime[i]:
		composite.append(i)
dp = [-inf] * least
dp[0] = 0
for i in range(len(dp)):
	for j in range(len(composite)):
		if composite[j] <= i:
			dp[i] = max(dp[i], dp[i - composite[j]] + 1)
		else:
			break
t = int(input())

def fun(n):
	left = (n - least) % 4
	n_copy = n
	n = least + left - 4
	dec = n_copy - n
	return (dec // 4, n)
for i in range(t):
	n = int(input())
	pre_process = 0
	if n >= least:
		(pre_process, n) = fun(n)
	if dp[n] == -inf:
		dp[n] = -1
	print(dp[n] + pre_process)


m = 16
ans = [-1] * m
ans[0] = 0
for i in range(m):
	for j in [4, 6, 9]:
		if i >= j and ans[i - j] != -1:
			ans[i] = max(ans[i], ans[i - j] + 1)
q = int(input())
for i in range(q):
	n = int(input())
	if n < m:
		print(ans[n])
	else:
		t = (n - m) // 4 + 1
		print(t + ans[n - t * 4])


import math
for i in range(int(input())):
	n = int(input())
	if n < 4 or n in [5, 7, 11]:
		print(-1)
	elif n % 2 == 0:
		print(n // 4)
	else:
		print(n // 4 - 1)


def shis(k):
	if k % 2 == 0 and k > 2:
		return k // 4
	elif k % 2 == 1 and k >= 13 or k == 9:
		return (k - 9) // 4 + 1
	else:
		return -1
m1 = []
n = int(input())
for i in range(n):
	m1.append(int(input()))
for i in range(n):
	print(shis(m1[i]))


n = int(input())
res = ''
for i in range(n):
	x = int(input())
	if x % 2 != 0:
		z = (x - 9) // 4
		if x == 1 or x == 3 or x == 5 or (x == 7) or (x == 11):
			res += '-1\n'
		else:
			res += str(z + 1) + '\n'
	else:
		z = x // 4
		if x < 4:
			res += '-1\n'
		else:
			res += str(z) + '\n'
print(res[:-1])


for _ in range(int(input())):
	num = int(input())
	dupe = num
	if num <= 3:
		print(-1)
	else:
		cnt = dupe // 4
		dupe = dupe % 4
		if dupe == 3:
			if cnt >= 3:
				print(cnt - 1)
			else:
				print(-1)
		elif dupe == 2:
			print(cnt)
		elif dupe == 1:
			if cnt >= 2:
				print(cnt - 1)
			else:
				print(-1)
		else:
			print(cnt)


def check_prime(q):
	i = 2
	while i * i <= q:
		if q % i == 0:
			return False
		i += 1
	return True

def solve(n):
	if n < 16:
		return first[n]
	else:
		answer = 0
		answer += n // 4
		n -= n // 4 * 4
		while first[n] == -1:
			answer -= 1
			n += 4
		answer += first[n]
		return answer
first = [-1, -1, -1, -1, 1, -1, 1, -1, 2, 1, 2, -1, 3, 2, 3, 2]
req = int(input())
for _ in range(req):
	print(solve(int(input())))


n = int(input())
for i in range(n):
	x = int(input())
	q = x // 4
	if q == 0 or (x % 2 != 0 and x < 13):
		if x == 9:
			print(1)
			continue
		print(-1)
	elif x % 2 == 0:
		print(q)
	else:
		print(q - 1)