vector<int> shortestPath(vector<vector<int>>& edges, int n,int m, int src){
// code here
vector<int>adj[n];
vector<int>visited(n,0);
for(int i = 0; i<m; i++){
int u = edges[i][0];
int v = edges[i][1];
adj[u].push_back(v);
adj[v].push_back(u);
}
queue<pair<int,int>>q;
vector<int>ans(n,-1);
ans[src]=0;
q.push({src,0});
visited[src]=1;
while(!q.empty())
{
int node=q.front().first;
int d=q.front().second;
q.pop();
for(auto it : adj[node])
{
if(visited[it]==0)
{
visited[it]=1;
ans[it]=d+1;
q.push({it,d+1});
}
}
}
// q.push(src);
// visited[src] = true;
// while(q.empty()==false){
// int u = q.front();
// q.pop();
// for(int e: adj[u]){
// if(visited[e] == false){
// res[e] = res[u] + 1;
// visited[e] = true;
// q.push(e);
// }
// }
// }
return ans;
}