#include <iostream>
#include <vector>
#include<queue>

using namespace std;
vector <int> t;
vector <vector <int>> v;
queue <int> q;
vector <int> vis;

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c;
    t.resize(b);
    v.resize(b);
    vis.resize(b);
    for(int i=0;i<b;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=0;i<b;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
           q.push(v[i][j]);
        }
    }
    for(int i=0;i<q.size();i++)
    {
        cout<<q.front()<<' ';
        q.pop();
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: