问题 C: Leshphon

内存限制:128 MB 时间限制:5 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Leshphon was a peaceful and beautiful village in Byteland until the nasty disease came here. There are n districts in Leshphon, connected by m directed roads such that you can reach every other district from any district via these directed roads. In other words, it is strongly connected.

To control the sources of infection and cut off the channels of transmission, the government of Byteland decides to close exactly three directed roads in Leshphon, such that the village is not strongly connected anymore. There may be many possible solutions, can you figure out the total number of them?

输入格式

The first line contains a single integer T (1T10), the number of test cases. For each test case:

The first line contains two integers n and m (3n503mn(n1)), denoting the number of districts and the number of roads.

Each of the following m lines contains two integers ui and vi (1ui,vinuivi), describing a directed road from the ui-th district to the vi-th district.

It is guaranteed that the village is strongly connected, and all the given m roads are pairwise different.

输出格式

For each test case, output a single line containing an integer, denoting the number of solutions.

输入样例 复制

1
4 7
1 2
2 3
3 4
4 1
1 3
2 4
3 1

输出样例 复制

34

分类标签