1304: triangle

内存限制:128 MB 时间限制:2.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

In an unidirectional graph containing no loops or multiple edges, we call an edge e's exp value exp(e) as the number of three-edge rings that contain edge e. In addition, we call a graph G(V,E)'s nice value nice(E)=min(exp(e),eE), and an edge e's nice value nice(e)=(max(nice(H)),eH and H is subgraph of G). Now with a given unidirectional graph without loops or multiple edges, you are required to calculate each edge's nice value.

输入

The first line contains only one integer T(1≤T≤10), which indicates the number of test cases.

For each case:

  • The first line contains two integers n,m(0≤n≤2000,0≤m≤5000), indicating the number of vertices and the number of edges, respectively;
  • In the next m lines, each line contains two integers u,v(1≤u,vn), indicating there is an edge between vertex u and vertex v.

输出

For each test case, output m lines, where the ith lines contains an integer indicating the nice value of the ith edge.

样例输入 复制

1
3 3
1 2
2 3
1 3

样例输出 复制

1
1
1