Recently, a number of gold mines have been discovered in Zorroming State. To protect this treasure, we must transport this gold to the storehouses as quickly as possible. Suppose that the Zorroming State consists of N towns and there are M bidirectional roads among these towns. The gold mines are only discovered in parts of the towns, while the storehouses are also owned by parts of the towns. The storage of the gold mine and storehouse for each town is finite. The truck drivers in the Zorroming State are famous for their bad temper that they would not like to drive all the time and they need a bar and an inn available in the trip for a good rest. Therefore, your task is to minimize the maximum adjacent distance among all the possible transport routes on the condition that all the gold is safely transported to the storehouses.
The input contains several test cases. For each case, the first line is integer . The second line is integers associated with the storage of the gold mine in every towns .The third line is also integers associated with the storage of the storehouses in every towns .Next is integer .Then M lines follow. Each line is three integers , and , means that there is a road between and for distance of . means end of the input.