시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 7 3 3 42.857%

문제

Pokemon Go just released the Buddy update. It lets you select a Pokemon to appear alongside your trainer’s avatar on your profile screen. As you walk with your buddy, it will find candy that can be used to evolve the Pokemon.

The Buddy system divides the Pokemons into 3 groups. Each group gives one candy upon walking for 1, 3, and 5 kilometers respectively

In this problem you will be given the Pokemon group G, the number of candies C you initially have, and the number of candies E required to evolve the Pokemon. You should calculate the number of Kilometers required to walk in order to evolve the Pokemon.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100).

Each test case consists of a line containing three space separated integers:

  • G: The group of the Pokemon (1 ≤ G ≤ 3)
  • C: The initial candies you have (0 ≤ C ≤ 100)
  • E: The candies required to evolve the Pokemon (1 ≤ E ≤ 100)

출력

For each test case, print a single line containing the number of Kilometers of walking required to Evolve the Pokemon.

예제 입력 1

2
1 15 51
1 18 21

예제 출력 1

36
3