Under construction

Still being built. Things may change

Grand Test

Time limit3sMemory limit512 MB

Summary
For each undirected graph, decide whether some pair of vertices admits three routes whose internal vertices and edges are all disjoint.
Level

Medium7 of 10

Topics
Graph, DFS, Binary search, Implementation
Solved
No attempts yet

Problem

Jeremy, Richard and James like to test cars. Deciding where to run a test is always hard. They pick a country and look at its cities and the two-way roads between them.

A test needs two different cities SS and FF and three routes from SS to FF. A route is a sequence of cities v1,v2,…,vkv_1, v_2, \dots, v_k with v1=Sv_1 = S, vk=Fv_k = F, and a road between viv_i and vi+1v_{i+1} for every ii with 1≤i≤k−11 \le i \le k-1. No city appears twice inside one route.

The three routes must meet two conditions. Every city other than SS and FF appears in at most one of the three routes. No road is used by more than one route.

When such SS, FF and three routes exist, each of the three takes a car in SS, drives along one of the routes and tries to reach FF before the others.

You are given the description of several countries. For each country, decide whether two cities and three routes can be chosen this way.

Input

The first line contains the number of countries TT (1≤T≤100 0001 \le T \le 100\,000). The descriptions of TT countries follow.

The first line of each country contains the number of cities nn and the number of roads mm (1≤n,m≤100 0001 \le n, m \le 100\,000). The next mm lines contain the cities uiu_i and viv_i at the ends of a road (1≤ui<vi≤n1 \le u_i < v_i \le n). All roads are two-way, and at most one road joins any pair of cities.

The sum of nn over all countries and the sum of mm over all countries are each at most 100 000100\,000.

Output

For each country print one line. Print YES if two cities SS and FF and three routes meeting the conditions exist, and NO otherwise. Print the answers in the order the countries are given in the input.

Examples2

  1. Example 1

    Input
    2
    6 6
    3 6
    3 4
    1 4
    1 2
    1 3
    2 3
    3 1
    1 2
    
    Expected output
    YES
    NO
    
  2. Example 2

    Input
    3
    3 3
    1 2
    1 3
    2 3
    4 5
    1 2
    1 3
    2 3
    2 4
    3 4
    4 3
    1 2
    1 3
    1 4
    
    Expected output
    NO
    YES
    NO