#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, k; cin >> n >> k;
vector<set<int>> adj(n);
int ed[n];
fill(ed, ed+n, 0);
int edges = 0;
for (int i = 0; i < k; i++){
int a, b; cin >> a >> b;
a--, b--;
edges += 2;
ed[a]++, ed[b]++;
adj[a].insert(b);
adj[b].insert(a);
}
int seen[n];
fill(seen, seen+n, 0);
stack<int> s;
function<void(int)> dfs = [&](int x){
// cout << x << "\n";
if (seen[x]){
while (s.top() != x){
cout << (s.top()+1) << " ";
seen[s.top()] = 0;
s.pop();
}
s.pop();
cout << (x+1) << "\n";
seen[x] = 0;
if (ed[x] != 0) dfs(x);
return;
}
s.push(x);
seen[x] = 1;
for (int nxt : adj[x]){
ed[x]--;
ed[nxt]--;
edges -= 2;
adj[x].erase(nxt);
adj[nxt].erase(x);
dfs(nxt);
return;
}
};
while (edges != 0){
fill(seen, seen+n, 0);
for (int i = 0; i < n; i++){
if (ed[i] != 0){
dfs(i);
}
}
}
}