#include<unordered_map>
#include<list>
#include<queue>
vector<int> shortestPath( vector<pair<int,int>> edges , int n , int m, int s , int t){
// Write your code here
//creating adj
unordered_map<int,list<int>>adj;
for(int i=0;i<edges.size();i++){
int u=edges[i].first;
int v=edges[i].second;
adj[u].push_back(v);
adj[v].push_back(u);
}
unordered_map<int,bool>visited;
unordered_map<int,int>parent;
queue<int>q;
q.push(s);
visited[s]=true;
parent[s]=-1;
//do BFS
while(!q.empty()){
int front=q.front();
q.pop();
//neighbour nodes and set parents of all
for(auto neighbour:adj[front]){
if(!visited[neighbour]){
q.push(neighbour);
visited[neighbour]=true;
parent[neighbour]=front;
}
}
}
//travese the shortest path from parent
vector<int>ans;
int curr=t;
while(curr!=s){
ans.push_back(curr);
curr=parent[curr];
}
ans.push_back(s);
reverse(ans.begin(),ans.end());
return ans;
}