#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
const int N = (int)1e6;
struct edge
{
int a, b, deleted, rev, i;
};
unsigned cur[N];
vector <edge> edges[N], answer;
int cnt = 0;
void dfs( int v )
{
while (cur[v] < edges[v].size())
{
cnt++;
edge e = edges[v][cur[v]++];
if (e.deleted)
continue;
edges[e.b][e.rev].deleted = 1;
dfs(e.b);
answer.push_back(e);
}
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++)
{
int a, b;
scanf("%d%d", &a, &b), a--, b--; // 1
int sa = edges[a].size();
int sb = edges[b].size();
edges[a].push_back({a, b, 0, sb + (a == b), i});
edges[b].push_back({b, a, 0, sa, i});
}
dfs(0);
fprintf(stderr, "graph.vector: cnt = %d\n", cnt);
fprintf(stderr, "time = %.2f\n", (double)clock() / CLOCKS_PER_SEC);
reverse(answer.begin(), answer.end());
// forn(i, answer.size())
// printf("%20d --> %d\n", answer[i].a + 1, answer[i].b + 1);
return 0;
}