Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

PCYCLE - Exploring the maze

In a maze, there are N rooms and some corridors connecting the rooms. There is at most one corridor connecting each pair of rooms.

An explorer wants to explore that maze. He'll start at a room and go along all the corridors so that each corridor is passed exactly once. Then he'll return to the starting point. Each corridor is assigned a value c meaning that when going along that corridor, the explorer's energy points will be add up with c unit(s) (c may be negative). The explorer starts with 0 energy point. He'll die if after passing a corridor, his energy point is negative.

Your task is to help the explorer find a safe journey satisfying the given conditions.

Input

  • The first line contains two integers N and M (1 ≤ N ≤ 200).
  • The ith line in the next M lines contains three integers u, v, c representing a corridor connecting room u and room v with c energy points. (|c| ≤ 10000).

Output

  • If there is no safe journey, print -1. Otherwise, print M+1 integers which are indexes of the rooms along the journey.

Example

Input
3 3
1 2 2
1 3 -1
2 3 -1

Output
2 1 3 2

Được gửi lên bởi:Nguyen Minh Hieu
Ngày:2008-07-05
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:VNOI Marathon '08 - Round 4
Problem Setter: Nguyễn Minh Hiếu

hide comments
2020-04-18 12:49:08
92.86 là sao mọi người :((
2018-05-21 02:24:53
Trâu cũng AC
2017-11-16 18:34:05
Mn ơi em code cho thử từng đỉnh làm đỉnh bắt đầu, xong in ra 1 2 3 1 với test đề bài, sao k được vậy ạ?
2016-10-28 08:55:44
có nhiều cách đi thì s?
2015-02-27 10:54:57 Sơn Tùng M-TP
Xuôi 0 điểm. Ngược 100. :D Buồn :( Cười quá!
2014-05-24 07:01:27 Anh Duc Le
Hình như có 1 test kq ra -1
2012-11-21 02:23:08 Try oh!
M<=(N*(N-1))/2
2012-09-22 11:02:26 Shinken Yellow
Hây ! M<=?
2011-07-16 14:50:43 uk
1 2 3 1 CŨNG ĐC MÀ
2011-07-16 14:20:57 ‮ ‮
M bao nhiêu vậy anh
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.