# [POI2010]MOS-Bridges

## 题意翻译

给定一个图，边有权值且正着走和逆着走有不同权值，在这个图上求一条最大边权最小的欧拉回路，从点 $1$ 出发，要求输出方案。
第一行包括两个整数 $n$ 和 $m$，分别代表点的个数和边的个数。接下来 $m$ 行每行包括 $4$ 个整数 $a,b,l,p$，分别代表边的两个端点和正着走的权值和逆着走的权值。
如果没有符合要求的路径输出 `NIE`，否则输出两行。第一行一个整数表示最小的权值，第二行 $m$ 个整数表示依次经过的边的编号。
Translated by @Schwarzkopf_Henkal

## 题目描述

San Bytecisco is a beautifully situated coastal town.
It consists of ![](http://main.edu.pl/images/OI17/mos-en-tex.1.png) small, yet densely populated islands, numbered from ![](http://main.edu.pl/images/OI17/mos-en-tex.2.png) to ![](http://main.edu.pl/images/OI17/mos-en-tex.3.png).
Certain islands are connected with bridges, used for (bidirectional) road traffic.
Each pair of islands can be connected with at most one bridge.
The islands are connected in such a way that every island can be reached from every other by using the bridges only.
Byteasar and Bytie are going for a bike trip in San Bytecisco.
The will start their ride at the island no. 1.
They intend to visit every island, while passing along every bridge once and ending the trip where it began, i.e., the island no. 1.
Being quite seasoned riders, they expect some serious trouble from... the wind!
After all, it is very windy along the coast, and especially so on the bridges between the islands. Obviously, depending on its speed and direction, the wind makes it hard to cross the bridge in different extent for either direction.
For simplicity we will assume for every bridge and direction of crossing, the opposing wind speed is constant.
Help Byteasar and Bytie to find a route as they desire that will in addition be the least tiresome. Byteasar and Bytie agreed on the maximum opposing wind speed as a measure of a route's tiresomeness.

## 输入输出格式

### 输入格式

In the first line of the standard input there are two integers separated by a single space: $n$ and $m$ ($2 \le n \le 1000$, $1 \le m \le 2000$), denoting the number of islands and the number of bridges in San Bytecisco respectively. The islands are numbered from 1 to n, while the bridges from 1 to m. The following lines specify the bridges. The line no.($n+1$) contains four integers $a_i,b_i,l_i,p_i$ ($1\le l_i,p_i \le 1000$), separated by single spaces. These denote that the bridge no. $i$ connects the islands no. $a$ and $b$. The opposing wind speeds are when one goes moves from to , and if one goes from $a$ to $b$.

### 输出格式

If there is no route satisfying the requirements of the daring two riders, the first and only line of the standard output should hold the word NIE (no in Polish).
Otherwise, the output should have two lines, specifying the least tiresome route over San Bytecisco.
The first line should hold the maximum opposing wind speed for that route, i.e., the number we wish to minimize.
The second line should hold ![](http://main.edu.pl/images/OI17/mos-en-tex.28.png) integers, separated by single spaces, giving the numbers of successive bridges one crosses on the least tiresome route.
Should there be more than one least tiresome route, your program can pick one arbitrarily.

## 输入输出样例

### 输入样例 #1

```
4 4
1 2 2 4
2 3 3 4
3 4 4 4
4 1 5 4
```

### 输出样例 #1

```
4
4 3 2 1
```

## 说明

$2 \le n \le 1000$，$1 \le m \le 20000$，$1 \le a_i,b_i \le n$，$a_i \neq b_i$，$1 \le l_i,p_i \le 1000$