Hacking

No attempts yetTime limit2sMemory limit256 MB

Problem

A hacker compromises one computer in a network. If computer a depends on computer b, then once b is infected, computer a becomes infected after s seconds.

Given the hacked computer and all dependencies, report how many computers become infected and how long until the last infection.

Input

The first line contains TT test cases (T100T \le 100). Each test case starts with nn, dd, and cc, followed by dd lines with aa, bb, and ss meaning a depends on b.

Output

For each test case, print the number of infected computers and the time of the last infection.