Problem: Bertown has n junctions and m bidirectional roads. We know that one can get from any junction to any other one by the existing roads. 

As there were more and more cars in the city, traffic jams started to pose real problems. To deal with them the government decided to make the traffic one-directional on all the roads, thus easing down the traffic. Your task is to determine whether there is a way to make the traffic one-directional so that there still is the possibility to get from any junction to any other one. If the answer is positive, you should also find one of the possible ways to orient the roads.

Input

The first line contains two space-separated integers n and m (2 ≤ n ≤ 105, n - 1 ≤ m ≤ 3·105) which represent the number of junctions and the roads in the town correspondingly. Then follow m lines, each containing two numbers which describe the roads in the city. Each road is determined by two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of junctions it connects.

It is guaranteed that one can get from any junction to any other one along the existing bidirectional roads. Each road connects different junctions, there is no more than one road between each pair of junctions.

Output

If there's no solution, print the single number 0. Otherwise, print m lines each containing two integers pi and qi — each road's orientation. That is the traffic flow will move along a one-directional road from junction pi to junction qi. You can print the roads in any order. If there are several solutions to that problem, print any of them.

Examples

Input

6 8
1 2
2 3
1 3
4 5
4 6
5 6
2 4
3 5


Output

1 2
2 3
3 1
4 5
5 6
6 4
4 2
3 5


Input

6 7
1 2
2 3
1 3
4 5
4 6
5 6
2 4


Output

0

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.io.DataInputStream; 
import java.io.FileInputStream; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
  
public class Main 
{ 
    static Graph graph[];
	static int time=0;
	static boolean ans=false;
	public static void add_edge(int u,int v)
	{
		graph[u].adj.add(graph[v]);
		graph[v].adj.add(graph[u]);
	}
	public static void there_is_a_bridge(int index)
	{
		Graph u=graph[index];
		u.vis=1;
		u.low=u.disc=++time;
		for(int i=0;i<u.adj.size();i++)
		{
			Graph v=u.adj.get(i);
		
			if(v.vis==0)
			{
				v.parent=u.val;
				there_is_a_bridge(v.val);
				u.low=Math.min(u.low,v.low);
				if(v.low>u.disc)
				{
					ans=true;
				}
			}
			else if(v.val!=u.parent)
			{
				u.low=Math.min(u.low,v.disc);
			}
		}
	
	}
	public static void dfs(int index)
	{
			Graph u=graph[index];
			u.vis=0;
			for(int i=0;i<u.adj.size();i++)
			{
				Graph v=u.adj.get(i);
				if(v.vis==-1)
				{
					System.out.println(u.val+" "+v.val);
					v.parent1=u.val;
					dfs(v.val);
				}
				else if(v.vis!=0)
				{
					System.out.println(v.val+" "+u.val);
				}
			}
			u.vis=1;
	}
    static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[64]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
  
        public int nextInt() throws IOException 
        { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do
            { 
                ret = ret * 10 + c - '0'; 
            }  while ((c = read()) >= '0' && c <= '9'); 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public long nextLong() throws IOException 
        { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public double nextDouble() throws IOException 
        { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
  
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
  
            if (c == '.') 
            { 
                while ((c = read()) >= '0' && c <= '9') 
                { 
                    ret += (c - '0') / (div *= 10); 
                } 
            } 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        private void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
  
    public static void main(String[] args) throws IOException 
    { 
        Reader sc=new Reader(); 
       int n=sc.nextInt();
		int m=sc.nextInt();
		graph=new Graph[n+1];
		for( int i=1;i<=n;i++)
		{
			graph[i]=new Graph(i);
		}
		for(int i=0;i<m;i++)
		{
			int u=sc.nextInt();
			 int v=sc.nextInt();
			 add_edge(u,v);
		}
		there_is_a_bridge(1);
			 if(ans)
			 {
				 System.out.println(0);
			 }
			 else
			 {
				 for(int i=1;i<=n;i++)
				 {
					 graph[i].vis=-1;
				 }
				 dfs(1);
			 }
		
    } 
}   

class Graph
{
	int vis,val;int parent;int low,disc;
	int parent1;
	ArrayList<Graph> adj;
	Graph(int val)
	{
		vis=0;
		adj=new ArrayList<>();
		this.val=val;
		low=-1;
		disc=-1;
		parent1=-1;
	}
}
/*
import java.io.*;
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
  
class Main 
{ 
static boolean prime[]; 
	public static void sieveOfEratosthenes(int n) 
    { 
       
        prime= new boolean[n+1]; 
        for(int i=0;i<n;i++) 
            prime[i] = true; 
          
        for(int p = 2; p*p <=n; p++) 
        { 
            
            if(prime[p] == true) 
            { 
                
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        } 
          
       
    } 
	
		
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		sieveOfEratosthenes(10000000); 
		int count1=0,count2=0;
		int a[]=new int[n];
		for( int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
			if(a[i]==1)
				count1++;
			else
				count2++;
		}
		
		long dp[][]=new long[count1+1][count2+1];
		ArrayList<Integer> adj=new ArrayList<>();
		long val=0;long max=0;
		for( int i=0;i<count1+1;i++)
		{
			for( int j=0;j<count2+1;j++)
			{
				if(i==0&&j==0)
					continue;
				
				long x=i*1+j*2;
				if(j==0)
				{
					if(prime[(int)x])
						dp[i][j]=dp[i-1][j]+1;
					else
						dp[i][j]=dp[i-1][j];
				}
				else if(i==0)
				{
					if(prime[(int)x])
						dp[i][j]=dp[i][j-1]+1;
					else
						dp[i][j]=dp[i][j-1];
				}
				else{
				if(prime[(int)x])
				{
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1])+1;
				}
				else
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			}
			}
		}
	
					
					
	}
}
*/