using System;
using System.Linq;
using System.Collections.Generic;

namespace GraphBridges
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            int v = info[0];
            int e = info[1];

            IDictionary<int, HashSet<int>> graph = new Dictionary<int, HashSet<int>>();
            for(int i = 0; i < e; ++i)
            {
                int[] edge = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
                if(!graph.ContainsKey(edge[0]))
                    graph.Add(edge[0], new HashSet<int>());
                if(!graph.ContainsKey(edge[1]))
                    graph.Add(edge[1], new HashSet<int>());
                graph[edge[0]].Add(edge[1]);
                graph[edge[1]].Add(edge[0]);
            }

            GraphAlgorithms rAlgorithms = new GraphAlgorithms();
            IList<int[]> bridges = rAlgorithms.FindBridges(graph);
            (bridges as List<int[]>).Sort((x, y) =>
            {
                Array.Sort(x);
                Array.Sort(y);
                if(x[0] == y[0])
                    return x[1] - y[1];
                return x[0] - y[0];
            });
            foreach (var br in bridges)
               System.Console.WriteLine(br[0] + " " + br[1]); 
        }
    }

    public class GraphAlgorithms
    {
        public virtual IList<int[]> FindBridges(IDictionary<int, HashSet<int>> graph)
        {
            HashSet<int> visited = new HashSet<int>();
            IDictionary<int, int> lowLink = new Dictionary<int, int>();
            IDictionary<int, int> ids = new Dictionary<int, int>();
            IList<int[]> bridges = new List<int[]>();
            int id = 0;
            foreach(var kv in graph)
            {
                if(visited.Contains(kv.Key))
                    continue;
                _FindBridges(kv.Key, -1, ref id, visited, lowLink, ids, graph, bridges);
            }
            return bridges;
        }

        protected virtual void _FindBridges(int v, int parent, ref int id, 
            HashSet<int> visited, 
            IDictionary<int, int> lowLink, 
            IDictionary<int, int> ids, 
            IDictionary<int, HashSet<int>> graph,
            IList<int[]> bridges)
        {
            int tp_id = id;
            ids.Assign(v, int.MaxValue, x => Math.Min(x, tp_id));
            lowLink.Insert(v, ids[v]);
            visited.Add(v);
            foreach (var adj_vert in graph[v])
            {
                if(adj_vert == parent)
                    continue;
                if(!visited.Contains(adj_vert))
                {
                    ++id;
                    _FindBridges(adj_vert, v, ref id, visited, lowLink, ids, graph, bridges);
                } 
                if(ids[v] < lowLink[adj_vert])
                    bridges.Add(new [] { v, adj_vert });
                lowLink[v] = Math.Min(lowLink[v], lowLink[adj_vert]);
            }
        }
    }

    public static class DictionaryHelpers
    {
        public static void Insert<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
        {
            if(!dictionary.ContainsKey(key))    
                dictionary.Add(key, default(TValue));
            dictionary[key] = value;
        }

        public static void Assign<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue default_value, Func<TValue, TValue> value_resolver)
        {
            if(!dictionary.ContainsKey(key))
                dictionary.Add(key, default_value);
            dictionary[key] = value_resolver(dictionary[key]);
        }
    }
}


Measured memory_bytes: 32964