#3. 爬山

爬山

说明

已知小珅和小泽是关系非常友好的朋友,并且它们都居住在同一座山上。山高 <math xmlns="http://www.w3.org/1998/Math/MathML">h 米,小珅在距离山脚 <math xmlns="http://www.w3.org/1998/Math/MathML">ha 米的地方居住,小泽在距离山脚 <math xmlns="http://www.w3.org/1998/Math/MathML">hb 米的地方居住。
小珅和小泽相约爬山,它们约定从同一天的白天开始从自己居住的地方开始往山顶爬,每天小珅和小泽都会根据自己的实际情况决定自己的行为:
  • 白天正常情况下,小珅每天爬 <math xmlns="http://www.w3.org/1998/Math/MathML">ua 米,小泽每天爬 <math xmlns="http://www.w3.org/1998/Math/MathML">ub 米,但是如果白天开始时对方比自己高,那么小珅会多爬 <math xmlns="http://www.w3.org/1998/Math/MathML">adda 米,小泽会多爬 <math xmlns="http://www.w3.org/1998/Math/MathML">addb 米。
  • 黑夜正常情况下,小珅每天掉 <math xmlns="http://www.w3.org/1998/Math/MathML">da 米,小泽每天掉 <math xmlns="http://www.w3.org/1998/Math/MathML">db 米,但是如果黑夜开始时对方比自己高,那么小珅会少掉 <math xmlns="http://www.w3.org/1998/Math/MathML">suba 米,小泽会少掉 <math xmlns="http://www.w3.org/1998/Math/MathML">subb 米。
现在请你帮助计算小珅小泽都爬到山顶所需要的时间(天数),你需要回答 <math xmlns="http://www.w3.org/1998/Math/MathML">t 个这样的问题。数据数据保证两人一定能够在有限步数内登上山顶。

输入格式

第一行,包含一个正整数 <math xmlns="http://www.w3.org/1998/Math/MathML">t

接下来 <math xmlns="http://www.w3.org/1998/Math/MathML">t 行,每行 <math xmlns="http://www.w3.org/1998/Math/MathML">11 个整数 <math xmlns="http://www.w3.org/1998/Math/MathML">h,ha,hb,ua,ub,adda,addb,da,db,suba,subb

输出格式

共 <math xmlns="http://www.w3.org/1998/Math/MathML">t 行,每行一个整数,表示答案。
2
8 1 3 3 2 1 1 2 1 1 1
30 2 20 14 2 3 1 2 1 1 0
3
6

提示

样例解释: 每天结束后小珅小泽的高度: (3,4), (5,6), (-,-) 

问题 <math xmlns="http://www.w3.org/1998/Math/MathML">2 中每天结束后小珅小泽的高度:(18,21), (-,22), (-,24), (-,26), (-,28), (-,-)

注意:爬上山顶之后就不会再继续往上爬了,也不会再继续往下掉了。 其中 - 表示已经爬上山顶。 

【数据范围】 对于 100 %  数据保证: 1 ≤ t ≤ 1 0 3, 1 ≤ h a , h b ≤ h ≤ 1 0 5  , 1 ≤ s u, b a ≤ d a < u a ≤ 1 0

来源

模拟