using namespace std;
#include <bits/stdc++.h>
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define maxN 200005
int n, q, pset[maxN], contain[maxN], box[maxN];
void initSet() {
fto(i, 1, n) pset[i] = i, contain[i] = i;
}
int findSet(int i) {
return (pset[i] == i) ? i : pset[i] = findSet(pset[i]);
}
void unionSet(int i, int j) {
pset[findSet(i)] = findSet(j);
}
bool isSameSet(int i, int j) {
return (findSet(i) == findSet(j));
}
int main () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
scanf("%d%d", &n, &q);
initSet();
fto(i, 1, q) {
int s, t;
scanf("%d%d", &s, &t);
int u = contain[s], v = contain[t];
contain[s] = 0;
if (v != 0) unionSet(u, v);
else contain[t] = u;
}
fto(i, 1, n) box[contain[i]] = i;
fto(i, 1, n) printf("%d ", box[findSet(i)]);
return 0;
}
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbWFwaWkgbWFwPGludCwgaW50PgojZGVmaW5lIGRlYnVnKGEpIGNvdXQgPDwgI2EgPDwgIjogIiA8PCBhIDw8IGVuZGwKI2RlZmluZSBmZHRvKGksIHIsIGwpIGZvcihpbnQgaSA9IHI7IGkgPj0gbDsgLS1pKQojZGVmaW5lIGZ0byhpLCBsLCByKSBmb3IoaW50IGkgPSBsOyBpIDw9IHI7ICsraSkKI2RlZmluZSBmb3JpdChpdCwgdHlwZSwgdmFyKSBmb3IodHlwZTo6aXRlcmF0b3IgaXQgPSB2YXIuYmVnaW4oKTsgaXQgIT0gdmFyLmVuZCgpOyBpdCsrKQojZGVmaW5lIGlpIHBhaXI8aW50LCBpbnQ+CiNkZWZpbmUgaWlpIHBhaXI8aW50LCBpaT4KI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIG1heE4gMjAwMDA1CgppbnQgbiwgcSwgcHNldFttYXhOXSwgY29udGFpblttYXhOXSwgYm94W21heE5dOwoKdm9pZCBpbml0U2V0KCkgewogICAgZnRvKGksIDEsIG4pIHBzZXRbaV0gPSBpLCBjb250YWluW2ldID0gaTsKfQoKaW50IGZpbmRTZXQoaW50IGkpIHsKICAgIHJldHVybiAocHNldFtpXSA9PSBpKSA/IGkgOiBwc2V0W2ldID0gZmluZFNldChwc2V0W2ldKTsKfQoKdm9pZCB1bmlvblNldChpbnQgaSwgaW50IGopIHsKICAgIHBzZXRbZmluZFNldChpKV0gPSBmaW5kU2V0KGopOwp9Cgpib29sIGlzU2FtZVNldChpbnQgaSwgaW50IGopIHsKICAgIHJldHVybiAoZmluZFNldChpKSA9PSBmaW5kU2V0KGopKTsKfQoKaW50IG1haW4gKCkgewogICAgI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgICAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgICAgICAvL2ZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgICAjZW5kaWYgLy8gT05MSU5FX0pVREdFCgogICAgc2NhbmYoIiVkJWQiLCAmbiwgJnEpOwogICAgaW5pdFNldCgpOwoKICAgIGZ0byhpLCAxLCBxKSB7CiAgICAgICAgaW50IHMsIHQ7CiAgICAgICAgc2NhbmYoIiVkJWQiLCAmcywgJnQpOwogICAgICAgIGludCB1ID0gY29udGFpbltzXSwgdiA9IGNvbnRhaW5bdF07CiAgICAgICAgY29udGFpbltzXSA9IDA7CiAgICAgICAgaWYgKHYgIT0gMCkgdW5pb25TZXQodSwgdik7CiAgICAgICAgZWxzZSBjb250YWluW3RdID0gdTsKICAgIH0KCiAgICBmdG8oaSwgMSwgbikgYm94W2NvbnRhaW5baV1dID0gaTsKCiAgICBmdG8oaSwgMSwgbikgcHJpbnRmKCIlZCAiLCBib3hbZmluZFNldChpKV0pOwoKICAgIHJldHVybiAwOwp9Cg==