Kita_masa is planning a trip around the world. This world has N countries and the country i has M_i cities. Kita_masa wants to visit every city exactly once, and return back to the starting city.
In this world, people can travel only by airplane. There are two kinds of airlines: domestic and international lines. Since international airports require special facilities such as customs and passport control, only a few cities in each country have international airports.
You are given a list of all flight routes in this world and prices for each route. Now it's time to calculate the cheapest route for Kita_masa's world trip!
The first line contains two integers N and K, which represent the number of countries and the number of flight routes, respectively. The second line contains N integers, and the i-th integer M_i represents the number of cities in the country i. The third line contains N integers too, and the i-th integer F_i represents the number of international airports in the country i. Each of the following K lines contains five integers [Country 1] [City 1] [Country 2] [City 2] [Price]. This means that, there is a bi-directional flight route between the [City 1] in [Country 1] and the [City 2] in [Country 2], and its price is [Price].
Note that cities in each country are numbered from 1, and the cities whose city number is smaller or equal to F_i have international airports. That is, if there is a flight route between the city c_1 in the country n_1 and the city c_2 in the country n_2 with n_1 \neq n_2, it must be c_1 \leq F_{n_1} and c_2 \leq F_{n_2}. You can assume that there's no flight route which departs from one city and flies back to the same city, and that at most one flight route exists in this world for each pair of cities.
The following constraints hold for each dataset:
Print a line that contains a single integer representing the minimum price to make a world trip.
If such a trip is impossible, print -1 instead.
4 6 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 2 1 1 4 1 1 2 1 3 1 1 2 1 4 1 2 3 1 4 1 1
4
2 16 4 4 2 2 1 1 1 2 1 1 1 1 3 2 1 1 1 4 1 1 2 1 3 1 1 2 1 4 2 1 3 1 4 1 2 1 2 2 1 2 1 2 3 2 2 1 2 4 1 2 2 2 3 1 2 2 2 4 2 2 3 2 4 1 1 1 2 1 1 1 1 2 2 2 1 2 2 1 2 1 2 2 2 1
8
2 2 2 1 1 1 1 1 1 2 1 1 1 2 1 1
-1