Bfs shortest path..........what is -1 given...isn't the output wrong given ? since no nodes is unvisited...coz all are in a single connnected compaonet

Consider an undirected graph consisting of ā€˜n’ nodes where each node is labeled from 1 to n and the edge between any two nodes is always of length 6 . We define node ā€˜s’ to be the starting position for a BFS.

Given ā€˜q’ queries in the form of a graph and some starting node, ā€˜s’ , perform each query by calculating the shortest distance from starting node ā€˜s’ to all the other nodes in the graph. Then print a single line of n-1 space-separated integers listing node s’s shortest distance to each of the n-1 other nodes (ordered sequentially by node number); if ā€˜s’ is disconnected from a node, print -1 as the distance to that node.

Input Format
The first line contains an integer,q , denoting the number of queries. The subsequent lines describe each query in the following format:

Each line contains N and M, the number of nodes and edges respectively.

The next m lines contains u and v means that there is edge between u and v .

The last line contains ā€˜s’, the starting node.

Constraints
1 <= q <= 10 2 <= n <= 1000 1 <= m <= (n*(n-1))/2 1 <= u,s,v <= n

Output Format
You have to print n-1 integer denoting the shortest distance from s to all other nodes excluding s itself.

Sample Input
2
4 2
1 2
1 3
1
3 1
2 3
2
Sample Output
6 6 -1
-1 6

hello @hg11110000 in this question as we have taken n as the input which is the total number of nodes .
and in that from 1 to 4 there are only 3 nodes i.e 1 ,2,3 and there is no node 4 in it so we cannot go to 4 thats why we have printed -1 for it .