for _ in range(input()):
    n = input()
    print[n / 4 - n % 2, -1][n in [1, 2, 3, 5, 7, 11]]

66a2ede04cf0c31a4f3dcc91090c4e6c0eb3e139
<mask token>

for _ in range(input()):
    n = input()
    print[n / 4 - n % 2, -1][n in [1, 2, 3, 5, 7, 11]]
