#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;
const int M = (int)1e6;

struct edge
{
  int a, b, deleted, i, next;
};

int cur[N], en = 2; // 0 + 2
edge edges[M * 2 + 2];
vector <edge> answer;

// (2, 3) (4, 5) (6, 7)
int cnt = 0;

void dfs( int v )
{
  while (cur[v])
  {
    cnt++;
    int &i = cur[v];
    edge e = edges[i];
    edges[i ^ 1].deleted = 1;
    i = e.next;
    if (e.deleted)
      continue;
    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
    edges[en] = {a, b, 0, i, cur[a]}, cur[a] = en++;
    edges[en] = {b, a, 0, i, cur[b]}, cur[b] = en++;
  }

  dfs(0);

  fprintf(stderr, "graph.list: 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;
}