QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#5365. Road Construction

Statistics

Xiao Zhen is the top scorer in the C City high school entrance examination, and his father, "Wangyou," is the mayor of C City.

C City is currently undergoing road construction. There are $2n$ residential areas and $m$ roads in C City. Each road connects two residential areas $u$ and $v$, satisfying $1 \le u \le n$ and $n+1 \le v \le 2n$. Now, C City needs to select some roads for maintenance; roads under maintenance cannot be used for travel. The citizens of C City believe that if a residential area cannot reach other areas via accessible roads, life in that area is very boring, and they will vent their anger online at Wangyou, causing his son, Xiao Zhen, to lose face. The citizens also believe that if, after road maintenance begins, a residential area is directly connected to more than $k$ roads that are not under maintenance, that area will become too noisy, and they will again vent their anger online at Wangyou, causing Xiao Zhen to lose face. Furthermore, if citizens from a residential area can return to their own area by traveling along a path of non-repeating roads, they will become confused, and they will once again vent their anger online at Wangyou, causing Xiao Zhen to lose face. To facilitate the management of citizens, Wangyou hopes to divide the citizens into as many groups as possible such that citizens in different groups cannot reach each other via accessible roads.

Xiao Zhen discovered that the scenery of each road is unique, and the scenery of the $i$-th road can be described by a positive integer $w_i$. Since Xiao Zhen has a private jet, he can ignore the roads and reach any vertex directly, but if a road is under maintenance, Xiao Zhen cannot enjoy the scenery on that road. He wants to maximize the total scenery value of the roads that are not under maintenance. Of course, he cannot disobey his father's wishes, and he does not want to lose face. Now, Xiao Zhen has come to you, hoping you can help him calculate the maximum possible total scenery value of the roads not under maintenance.

Input

The first line contains three positive integers $n$, $m$, and $k$.

The following $m$ lines each contain three positive integers $u_i, v_i, w_i$, where $1 \le u_i \le n$ and $n+1 \le v_i \le 2n$, representing an edge connecting the $u_i$-th and $v_i$-th residential areas with a scenery value of $w_i$.

The input data guarantees that there is at most one road between any two residential areas.

Output

A single line containing two positive integers, representing the number of roads under maintenance and the maximum total scenery value.

If Xiao Zhen loses face regardless of which roads are chosen for maintenance, output "FACELESS" (without quotes).

Examples

Input 1

3 5 2
1 4 1
1 5 2
1 6 3
2 4 4
2 5 5

Output 1

FACELESS

Input 2

3 4 2
1 4 1
2 4 2
3 5 3
3 6 4

Output 2

0 10

Subtasks

The evaluation uses a subtask system. To receive points for a subtask, you must pass all data for that subtask.

Subtask 1 [8pts]: $n \le 10$, $m \le 20$

Subtask 2 [30pts]: $k = 2$

Subtask 3 [30pts]: $k = n$

Subtask 4 [32pts]: No special conditions

In all the above subtasks, $1 \le k \le n \le 100$, $1 \le m \le 2000$, $0 \le w \le 10000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.