Apple’s birthday is coming, so Groundhog wants to buy gifts for Apple. The city where Groundhog is located has a bustling shopping belt consisting of

traffic stops and

undirected shopping streets, and it is guaranteed that any two traffic stops can reach each other only through these shopping streets. The

shopping street connects the sites

and

. On each shopping street, Groundhog can cross it from the left or right side of the street, which costs

and

respectively.(Whether he crosses from

to

or from

to

, he can choose to cross from the left or the right side of the street)
Of course, Groundhog did not forget to buy gifts for Apple. On each shopping street, if he pass by on the left, he can spend

to buy a gift, and when he pass by on the right, he can spend

to buy another.
Apple wanted

birthday gifts, so she made

gift requests. For the

gift request, Groundhog can start from the site

and walk along the shopping street to

(each shopping street on this path must be passed through). For each shopping street, he can choose to cross from the left or right (the choice of different shopping streets is independent), and choose exactly one gift along the way to give to Apple (note that if Groundhog crosses a shopping street from the left, then the gift on the right will not be counted and vice versa). In order to reflect his concern for Apple, Groundhog will always choose the most expensive gift along the way; but Groundhog is not wealthy, so he will choose a scheme to minimize the total cost of his travel expenses and money used to buy gifts.
Groundhog is lazy so he throws this question to you. You need to know how much Groundhog will cost for each gift request from Apple (including the cost of buying gifts and road expenses).