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.*;

public class J{
	public static class dfs_tree {		
		List<Integer>[] adj;
		int[] lvl;
		public dfs_tree(int n) {
			adj = new List[n];
			lvl= new int[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<Integer>();
			}
		}
		void add(int a, int b) {
			adj[a].add(b);
			adj[b].add(a);
		}
		void dfs(int i, int p) {
			if (lvl[i] != 0)return;
			lvl[i] = lvl[p]+1;
			for (int x: adj[i]) {
				if (lvl[x] != 0) continue;
				dfs(x, i);
			}
		}
	}

	public static Reader sc = new Reader();
	//public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	static int bc = 0;
	static void dfs(int i) {
		dp[i] = 0;
		for (int x: dtree.adj[i]) {
			if (dtree.lvl[x] == dtree.lvl[i]+1) {
				a.add(i);
				b.add(x);
				dfs(x);
				dp[i] += dp[x];
				
			}
			else {
				if (dtree.lvl[x] + 1 != dtree.lvl[i] && dtree.lvl[x] < dtree.lvl[i]) {
					a.add(i);
					b.add(x);
				}
				if (dtree.lvl[x] < dtree.lvl[i]){
					dp[i]++;
				}
				else {
					dp[i]--;
				}
			}
		}
		dp[i]--;
		if (dtree.lvl[i] > 1 && dp[i] == 0) bc++;  
	}
	static int[] dp;
	static dfs_tree dtree;
	static List<Integer> a = new ArrayList<Integer>(), b = new ArrayList<Integer>();
	public static void main(String[] args) throws IOException {
		//BufferedReader br = new BufferedReader(new FileReader("input.in"));
		int n = sc.nextInt(), m = sc.nextInt();
		dp = new int[n];
		dtree = new dfs_tree(n);
		for (int i = 0; i < m; i++) {
			dtree.add(sc.nextInt()-1, sc.nextInt()-1);
		}
		dtree.dfs(0,0);
		dfs(0);

		if (bc == 0) {
			for (int i = 0; i < a.size(); i++) {
				out.println(a.get(i) + 1 + " " + (1+b.get(i)));
			}
		}
		else out.println(0);
		
		out.close();
	}

	static void mergeSort(long[] a) {
		if (a.length < 2)
			return;
		long[] x = new long[a.length / 2];
		long[] y = new long[a.length - a.length / 2];
		for (int i = 0; i < x.length; i++)
			x[i] = a[i];
		for (int i = 0; i < y.length; i++)
			y[i] = a[i + x.length];
		mergeSort(x);
		mergeSort(y);
		int i = 0, j = 0, k = 0;
		while (j < x.length && k < y.length) {
			if (x[j] < y[k]) {
				a[i] = x[j];
				j++;
			} else {
				a[i] = y[k];
				k++;
			}
			i++;
		}
		while (j < x.length) {
			a[i] = x[j];
			j++;
			i++;
		}
		while (k < y.length) {
			a[i] = y[k];
			k++;
			i++;
		}
	}

	static long ceil(long a, long b) {
		return (a + b - 1) / b;
	}

	static long gcd(long a, long b) {
		while (b != 0) {
			long t = a;
			a = b;
			b = t % b;
		}
		return a;
	}

	static long powMod(long base, long exp, long mod) {
		if (base == 0 || base == 1)
			return base;
		if (exp == 0)
			return 1;
		if (exp == 1)
			return base % mod;
		long R = powMod(base, exp / 2, mod) % mod;
		R *= R;
		R %= mod;
		if ((exp & 1) == 1) {
			return base * R % mod;
		} else
			return R % mod;
	}

	static long pow(long base, long exp) {
		if (base == 0 || base == 1)
			return base;
		if (exp == 0)
			return 1;
		if (exp == 1)
			return base;
		long R = pow(base, exp / 2);
		if ((exp & 1) == 1) {
			return R * R * base;
		} else
			return R * R;
	}

	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, Integer.max(cnt - 1, 0));
		}

		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();
		}
	}

}