Frame-workout 2#980

Frame-workout 2

1 second
64 megabytes
Very easy

Find a pair of vertices in a complete undirected weighted graph according to specified criteria.

Input

The input file contains a number (2 \leq N \leq 100) and the adjacency matrix of a complete undirected weighted graph (a complete graph is a graph in which there are edges between all pairs of vertices). All edge weights are natural numbers from to . Then, numbers are given, each either or —these numbers are assigned to the vertices. It is guaranteed that there is at least one and at least one .

Output

Find and print two vertices such that:

  • the first vertex is assigned

  • the second vertex is assigned

  • the edge connecting these two vertices has the minimal possible weight

If there are multiple such pairs, output any of them.

Examples

Example 1

Loading
Loading