#P7161. Luxury cruise ship

    ID: 6018 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2022“杭电杯”中国大学生算法设计超级联赛(2)

Luxury cruise ship

Problem Description

Kayzin plans to buy a luxury cruise ship which will cost N coins. But Kayzin didn't have enough coins, so Kayzin decided to start saving coins.

Kayzin will put 7 or 31 or 365 coins into his piggy bank each day. Now Kayzin wants to know at least how many days he will need to "exactly"(No more and no less) scrape together the money for buying a luxury cruise.

If Kayzin can't "exactly" scrape together the money for buying a luxury cruise, print -1.

Input

The first line contains an integer $T(T≤1000)$ . Then $T$ test cases follow.

For one case, the first line contains an integer $N$ $(1≤N≤10^{18})$ , $N$ denotes the coins that a luxury cruise ship will cost.

Output

Print an integer for each case, indicating the minimum number of days Kayzin needs.

If Kayzin can't "exactly" scrape together the money for buying a luxury cruise, print -1.

5 14 38 55 403 996
2 2 -1 3 16