1487_E. Cheap Dinner
Ivan wants to have a good dinner. A good dinner should consist of a first course, a second course, a drink, and a dessert.

There are n_1 different types of first courses Ivan can buy (the i-th of them costs a_i coins), n_2 different types of second courses (the i-th of them costs b_i coins), n_3 different types of drinks (the i-th of them costs c_i coins) and n_4 different types of desserts (the i-th of them costs d_i coins).

Some dishes don't go well with each other. There are m_1 pairs of first courses and second courses that don't go well with each other, m_2 pairs of second courses and drinks, and m_3 pairs of drinks and desserts that don't go well with each other.

Ivan wants to buy exactly one first course, one second course, one drink, and one dessert so that they go well with each other, and the total cost of the dinner is the minimum possible. Help him to find the cheapest dinner option!

Input

The first line contains four integers n_1, n_2, n_3 and n_4 (1 ≤ n_i ≤ 150000) — the number of types of first courses, second courses, drinks and desserts, respectively.

Then four lines follow. The first line contains n_1 integers a_1, a_2, ..., a_{n_1} (1 ≤ a_i ≤ 10^8), where a_i is the cost of the i-th type of first course. Three next lines denote the costs of second courses, drinks, and desserts in the same way (1 ≤ b_i, c_i, d_i ≤ 10^8).

The next line contains one integer m_1 (0 ≤ m_1 ≤ 200000) — the number of pairs of first and second courses that don't go well with each other. Each of the next m_1 lines contains two integers x_i and y_i (1 ≤ x_i ≤ n_1; 1 ≤ y_i ≤ n_2) denoting that the first course number x_i doesn't go well with the second course number y_i. All these pairs are different.

The block of pairs of second dishes and drinks that don't go well with each other is given in the same format. The same for pairs of drinks and desserts that don't go well with each other (0 ≤ m_2, m_3 ≤ 200000).

Output

If it's impossible to choose a first course, a second course, a drink, and a dessert so that they go well with each other, print -1. Otherwise, print one integer — the minimum total cost of the dinner.

Examples

Input


4 3 2 1
1 2 3 4
5 6 7
8 9
10
2
1 2
1 1
2
3 1
3 2
1
1 1


Output


26


Input


1 1 1 1
1
1
1
1
1
1 1
0
0


Output


-1

Note

The best option in the first example is to take the first course 2, the second course 1, the drink 2 and the dessert 1.

In the second example, the only pair of the first course and the second course is bad, so it's impossible to have dinner.
```python
MAX_VAL = 2 ** 31


def prepare_values(vals):
    zipped_vals = list(zip(vals, range(1, len(vals) + 1)))
    zipped_vals.sort()
    pairs = [(old_i, i) for i, (val, old_i) in enumerate(zipped_vals, 1)]
    return zipped_vals, dict(pairs)


def renumber_ids(dic, l):
    return [dic[x] for x in l]


def get_first_absent(l):
    l.sort()
    i = 1
    for x in l:
        if i != x:
            return i
        i += 1

    return i


def read_mismatches():
    n = int(input())
    mismatches = dict()
    for _ in range(n):
        x, y = map(int, input().split())
        l = mismatches.get(x, [])
        l.append(y)
        mismatches[x] = l

    return n, mismatches


def accumulate_cost(to_accumulate, from_accumulate, mismatches):
    n = len(to_accumulate)

    from_zipped, from_dic = prepare_values(from_accumulate)

    for x in range(1, n + 1):
        l = mismatches.get(x, [])
        renumbered_l = renumber_ids(from_dic, l)
        first_absent = get_first_absent(renumbered_l)

        if first_absent > len(from_accumulate):
            to_accumulate[x - 1] = MAX_VAL
        else:
            to_accumulate[x - 1] += from_zipped[first_absent - 1][0]

    return 0


def solution():
    n1, n2, n3, n4 = map(int, input().split())

    first_course = list(map(int, input().split()))
    second_course = list(map(int, input().split()))
    drink = list(map(int, input().split()))
    dessert = list(map(int, input().split()))

    m1, fc_sc_mismatch = read_mismatches()
    m2, sc_drink_mismatch = read_mismatches()
    m3, drink_dessert_mismatch = read_mismatches()

    # drinks
    accumulate_cost(drink, dessert, drink_dessert_mismatch)

    # second_course
    accumulate_cost(second_course, drink, sc_drink_mismatch)

    # first course
    accumulate_cost(first_course, second_course, fc_sc_mismatch)

    result = min(first_course)
    print(-1 if result >= MAX_VAL else result)
    
solution()
```