#1235 : New Teaching Buildings

时间限制:2000ms
单点时限:2000ms
内存限制:256MB

描述

Thanks to the generous finance income, Programming Monkey Elementary School is going to build three new teaching buildings.

The school could be seen as a connected graph with n vertices and m edges, in which every vertex belongs to at most a single cycle(the one consists of a sequence of vertices starting and ending at the same vertex, with each two consecutive vertices in the sequence adjacent to each other in the graph and no repetitions of vertices other than the repetition of starting and ending vertex.). For the sake of students’ physical well-being, the principal decides to find the longest “Y shape road” in the school and build the three new buildings in its three ends. A “Y shape road” contains three simple roads in the graph, which begins from a same vertex and don’t have any common vertices except it. As we know, a simple road is a finite sequence of edges which connect a sequence of vertices which are all distinct from one another. The longest one is exactly the one contains the largest length of roads.

Can you help him?

输入

There are no more than 600 test cases, and most cases are very small.

The first line of the input contains an integer T which means the number of test cases.

The first line of each test case contains two integers, n, m, which are the number of vertices and the number of edges. All vertices are numbered from 1 to n.

The next m lines, each line consists of three integers, u, v, w, which means there is an undirected edge between u and v, and its length is w.

Please note that n ≤ 100,000,w ≤ 1000

输出

For each test case, output the length of the largest “Y shape road”.

样例输入
2
5 5
1 2 9
5 1 2
2 5 3
3 4 6
3 1 2
3 3
1 2 1
2 3 3
3 1 2
样例输出
19
0

最新文章

  1. Linux(Centos)之安装Redis及注意事项
  2. /etc/sudoers文件损坏修复
  3. MySQL主主双机负载均衡
  4. IOS开发数据库篇—SQLite模糊查询
  5. rel=nofollow
  6. 获取手机内存\可用内存\单个APP运行内存
  7. [转载]# Ajax异步请求阻塞情况的解决办法
  8. 用eval 动态编译代码
  9. clang和gcc消除警告
  10. Javascript:数组和字符串的相互转化
  11. php引用传值详解
  12. HTTP 内容编码,也就这 2 点需要知道 | 实用 HTTP
  13. python介绍与入门
  14. PAT 乙级 1078 字符串压缩与解压 (20)
  15. xcode 拷贝新的ios image 进去以后 出现 the divices is locked
  16. Spring mvc RequestContextHolder分析
  17. 如何构建Win32汇编的编程环境(ONEPROBLEM个人推荐)
  18. Java中的内部类介绍(1)
  19. IT兄弟连 JavaWeb教程 MVC设计模式
  20. 搭建Sql Server AlwaysOn 视频教程

热门文章

  1. 太极图HTML+CSS(可旋转)代码记录
  2. ryu—流量监视
  3. (06)-Python3之--判断、循环
  4. Mac下IDEA激活Jrebel
  5. __del__ PyPy和CPython的不同点 动态编译(注意不是解释) 析构函数被调用的次数
  6. 向同一个模型的外键反向关联名称产生了冲突 Django迁移
  7. Linux 中的文件属性
  8. 分布式缓存 — MongoDB
  9. 浅谈OSI参考模型(七层模型)
  10. Jenkins(4)docker容器内部修改jenkins容器时间