#K57597. Taco Packaging
Taco Packaging
Taco Packaging
In this problem, you are given a target number of stones, \(M\). You have two types of packages: one containing 4 stones and the other containing 7 stones. Your task is to determine the minimal number of packages required to accumulate exactly \(M\) stones. If it is impossible to collect exactly \(M\) stones using these packages, your program should output \(-1\).
Formally, find non-negative integers \(x\) and \(y\) such that:
[ 4x + 7y = M ]
and the value \(x+y\) is minimized. If no such pair exists, output \(-1\).
inputFormat
The first line contains an integer \(T\), the number of test cases. Each of the next \(T\) lines contains a single integer \(M\), representing the desired number of stones.
outputFormat
For each test case, output a single line containing the minimal number of packages required to reach exactly \(M\) stones. If it is impossible, output \(-1\).
## sample3
29
15
8
5
3
2
</p>