Under construction

Still being built. Things may change

Disposable Switches

Time limit4sMemory limit512 MB

Summary
Find the switches that never lie on an optimal path from switch 1 to switch n, whatever the cable speed and per-cable overhead turn out to be.
Level

Hard8 of 10

Topics
Graph, Shortest path, Geometry
Solved
No attempts yet

Problem

You were recently hired by Netwerc Industries as a network engineer. Your first task is to assess their large, dated office network. You have mapped the network, which consists of switches and the cables between them. You suspect that some switches are redundant and that others are not used at all. Before you present this to your boss, you decide to write a program to test the claim.

The data consists of the network map and the length of each cable. A packet sent across a cable of length ℓ\ell takes time

ℓv+c\frac{\ell}{v} + c

where vv is the propagation speed of the cable and cc is the overhead of transmitting the packet on and off the cable. The values of vv and cc are unknown. You only know that they are real numbers with v>0v > 0 and c≥0c \ge 0, and that they are the same for all cables. Network routing ensures that a packet takes an optimal path, meaning a path that minimizes the total transit time.

Given the network map and the cable lengths, determine which switches can never be part of an optimal path from switch 1 to switch nn, no matter what the values of vv and cc are.

Input

The first line has two integers nn and mm (2≤n≤2 0002 \le n \le 2\,000, 1≤m≤1041 \le m \le 10^4), the number of switches and cables. The switches are numbered 1 to nn. Each of the next mm lines has three integers aa, bb, and ℓ\ell (1≤a,b≤n1 \le a, b \le n, 1≤ℓ≤1091 \le \ell \le 10^9), describing a cable of length ℓ\ell between switches aa and bb. At most one cable connects any pair of switches, and no cable connects a switch to itself. There is a path between every pair of switches.

Output

First output a line with an integer kk, the number of switches that can never be part of an optimal path from switch 1 to switch nn. Then output a line with the kk indices of these switches in increasing order.

Examples3

  1. Example 1

    Input
    7 8
    1 2 2
    1 3 1
    1 4 3
    2 6 1
    2 7 2
    3 5 1
    4 7 2
    5 7 1
    
    Expected output
    2
    4 6
    
  2. Example 2

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

    Input
    5 6
    1 2 2
    2 3 1
    3 5 2
    1 4 3
    4 5 3
    1 5 6
    
    Expected output
    1
    4