A group of friends plans to collect funds at Bengal University to support their ailing…
- User
A group of friends plans to collect funds at Bengal University to support their ailing friend.They visit the university and obtain approval from the proctor. The proctor informs them thatthere are N academic buildings on the campus, and they are only allowed to collect funds withinthese academic buildings. Additionally, the proctor mentions that once the fund collection iscomplete, they should meet him again in his chamber, which is located in academic buildingnumber one.At Bengal University, there are academic buildings numbered from 1 to N, which are connectedby elevator bridges. Each building acts like one component. An elevator bridge that connectsacademic building number x with academic building number y, serving as a bi-directionalconnection between them.Their plan is detailed below:● They will begin their journey at academic building one and continue in increasing orderthrough buildings 2, 3, ..., up to N.● They will start collecting donations upon entering each academic building, ensuring thatthey collect donations from each building only once and in an ethical manner.● They are allowed to enter any building multiple times, as long as they travel throughbuildings where donations have already been collected.It takes an hour to travel between two buildings that are directly connected by a bridge. The timerequired to reach one building to another is the same as the time needed to finish collecting fundsfrom it.NoteThe initial travel time to Building 1 is zero hours, but the fund collection time required atBuilding 1 is one hour.InputThe first line consists of a single integer t (1 ≤ t≤ 100), representing the number of test cases.Each test case follows,The first line of each test case contains two integers n and m (1 ≤ n ≤100 and 1≤ m ≤ 4*103),representing the number of academic buildings and the number of elevator bridges.Then m lines follow,Each consists of two integers ai and bi (1 ≤ ai, bi ≤ n, and ai ≠ bi), representing the elevator bridgethat is constructing a bridge between the buildings of ai and bi.OutputFor each test case, According to their plan, if they collect donations successfully from eachacademic building then print “YES”(without quote) on the first line, and on the next line printthe minimum time required in hours. Otherwise, print "NO" (without quotes)
- Assistant