The year is 2020. You and your group are trapped in a town inside a city that zombies have wrecked. Your group is already infected, so you have to reach a hospital and get treated before you turn. Everyone in the group is a scientist, so sneaking past the zombies is safer than charging at them to force a way through. Zombies are everywhere, and on some roads sneaking through takes longer than on others. Splitting into several groups that move on their own is sometimes far safer than travelling together.
The infection did not go far enough to give these zombies eyes in the back of their heads. On some roads one direction is easy to sneak along while going back the other way is hard or impossible.
Find the largest number of people in your group who can avoid the zombies and reach a hospital before they turn.
The first line holds the number of test cases. Each test case has the form below. Every value is an integer.
The group is at place i at time 0. People step onto a road at integer times, and someone who steps onto a road at time τ arrives at the far place at time τ+t.
Between any pair of places there are at most 2 roads, one per direction. Every place is safe enough to stand and wait in for as long as you like, and there is no limit on how many people a place holds.
For each test case, print on its own line the largest number of people who reach a hospital without being infected.