Under construction

Still being built. Things may change

Tourist Petr

Time limit2sMemory limit1024 MB

Summary
Find a simple path of at most 4 cities with the largest total enjoyment, given each city's value and the train routes between cities, and print the cities in visiting order.
Level

Medium5 of 10

Topics
Graph, Brute force, Sorting
Solved
No attempts yet

Problem

Vera met Petr, a friendly volleyball player and tractor driver, while on vacation in a Warm Country. Petr, a tourist, plans to travel through European cities after the vacation. Europe has a well-developed transport system. There are VV cities that interest Petr and EE night train routes. Each route connects two different cities, and the trip takes one night. Trains run in both directions.

Petr wants the whole trip to take no more than four days. He spends exactly one day sightseeing in each city, and he spends each night on a night train between cities. Petr does not want to visit any city more than once.

For each city, Petr has estimated his expected enjoyment pip_i of visiting it. Find a route that gives Petr the greatest total enjoyment.

Input

The first line contains two integers VV and EE (1≤V,E≤3×1051 \le V, E \le 3 \times 10^5), the number of cities and the number of train routes.

The second line contains VV integers p1,p2,…,pVp_1, p_2, \ldots, p_V (1≤pi≤1081 \le p_i \le 10^8), where pip_i is the expected enjoyment of visiting city ii.

Each of the next EE lines describes a route with two different integers aia_i and bib_i (1≤ai,bi≤V1 \le a_i, b_i \le V), the numbers of the cities that the route connects. There is at most one route between any pair of cities.

Output

On the first line, print the number KK of cities on the optimal route (1≤K≤41 \le K \le 4). On the second line, print the numbers of these cities in the order of the visit. Cities are numbered starting from 1. If several optimal routes exist, print any of them.

Examples2

  1. Example 1

    Input
    5 4
    4 2 3 1 5
    1 2
    2 3
    3 4
    4 5
    
    Expected output
    4
    2 3 4 5
    
  2. Example 2

    Input
    4 3
    1 2 3 4
    1 2
    1 3
    1 4
    
    Expected output
    3
    4 1 3