Problem of Bilocation

2.9

20 votes
Very-Easy
Problem

Anurag is posed with a very serious problem. He will be in London during the summers from days [a,b] for an internship. But he also wants to attend the ACM-ICPC World Finals with his team to be held in Thailand during [c,d] days. The opening ceremony for the World Finals will be held on c day. He found out that it would take him S time (in days) to travel from London to Thailand. He wonders what is the maximum time L in the interval [a,b], at which he will have to leave so as to reach Thailand on or before the opening ceremony.
If it is not possible for him to reach on or before the opening ceremony, print STAY IN LONDON.

Input

  • The first line contains a single integer T, denoting the number of test cases.
  • Next T lines contain five integers each a b c d and S.

Output

  • For each test case, you need to output the answer in a new line.
Constraints
  • 1 ≤ T ≤ 100000
  • 1 ≤ ab ≤ 100000
  • bcd ≤ 100000
  • 1 ≤ S ≤ 100000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?