8497: Luxury cruise ship

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

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.

输入格式

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

For one case, the first line contains an integer N(1N1018) , N denotes the coins that a luxury cruise ship will cost.

输出格式

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