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.math.BigInteger;
import java.util.*;

public class E implements Runnable {
	private InputReader in;
	private PrintWriter out;
	public static void main(String[] args) {
		new E().run();
	}
	public E() {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}
	
	private static final int MAXN = 100000+5;
	private static final int MAXM = 300000+5;
	
	int N, M;
	
	List<Integer>[] adj = new ArrayList[MAXN];
	List<Integer> stack = new ArrayList<Integer>(MAXN);
	int[] time = new int[MAXN];
	List<String> ways = new ArrayList<String>(MAXM);
	
	public void run() {
	    N = in.readInt();
	    M = in.readInt();
	    
	    for (int i = 0; i < N; i++)
	        adj[i] = new ArrayList<Integer>();
	    
	    int p, q;
	    for (int i = 0; i < M; i++) {
	        p = in.readInt()-1;
	        q = in.readInt()-1;
	        adj[p].add(q);
	        adj[q].add(p);
	    }
	    
	    if (visit(0,1) == NO)
	    	out.println(0);
	    else {
	    	for (String s : ways)
	    		out.println(s);
	    }
	    
	    out.close();
	}
	
	final static int NO = 2*MAXN;
	final static int YES = -1;
	
	private int visit(int s, int lev) {
		//stack.add(s);
		time[s] = lev;
		
		//System.out.println("Visiting "+(s+1)+" level "+lev);
		if (lev == 2)
			ways.add(String.format("%d %d", 1, s+1));
		
		int res = NO;
		for (int i = 0; i < adj[s].size(); i++) {
			int t = adj[s].get(i);
			
			
			if (lev != 1 && time[t] < lev-1)
				ways.add(String.format("%d %d", s+1, t+1));
			
			//System.out.println("    Looking at "+(t+1));
			// Special case for handling coming back
			if (t == 0 && lev > 2) {
				res = YES;
				continue;
			}
			else {
				if (time[t] != 0) {
					// ignorerer upstack, det er lige som ikke at have fundet noget
					// marker downstack, det er en "m[ske" vej.
					// men m[ ikke bare tage parent.
					if (time[t] < lev-1) {
						res = Math.min(res, time[t]);
						//if (res == NO) res = time[t];
						//else if (res == YES) res = YES;
						//else res = Math.min(res, time[t]);
					}
					continue;
				}
				int r = visit(t, lev+1);
				// marker downstack, m[ske er den bedre end den nuv;rende 
				// fejl på opstack, men sker aldrig
				// fejl p[ fejl
				// alt er godt p[ yes: al afh;ngighed er downstack er p[ plads
				if (r == NO) return NO;
				res = Math.min(res, r);
				//if (res == NO) res = r;
				//else if (r == YES) {
				//	res = YES; // found a rescue
				//}
				//else {
				//	res = Math.min(res, r); // found a more likely way out
				//}
			}
		}
		if (res >= lev) {
		//if (res == NO || (res != YES && res >= lev)) {
			//System.out.println("fail");
			return NO;
		}
		
		//System.out.println("Node "+(s+1)+" returnerer "+res);
		//stack.remove(stack.size()-1);
		//time[s] = 0; // lidt lige meget NEJ
		return res;
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1000];
		private int curChar, numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int readInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long readLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private String readLine0() {
			StringBuffer buf = new StringBuffer();
			int c = read();
			while (c != '\n' && c != -1) {
				buf.appendCodePoint(c);
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0)
				s = readLine0();
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines)
				return readLine();
			else
				return readLine0();
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char readCharacter() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			return (char) c;
		}

		public double readDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
	}
}