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

public class Main {
	static final int M = 1000000007;

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long[] readArrayLong(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[] readArrayInt(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {return Double.parseDouble(next());}
	}

	// sorting template
	static void sortLong(long[] a) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static void sortInt(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class Graph {
		private ArrayList<Integer> adj[];
		public String s;
		public String dpch;

		Graph(int n) {
			adj = new ArrayList[n + 1];
			for (int i = 1; i <= n; i++) {
				adj[i] = new ArrayList<>();
			}
		}

		void addEdges(int u, int v) {
			adj[u].add(v);
			adj[v].add(u);
		}

		void dfs(int node, int par, boolean[] vis, int timer) {
			vis[node] = true;
			in[node] = timer++;
			for(int u: adj[node]){
				if(u==par) continue;
				if(vis[u]){
					if(in[node]>in[u])
					System.out.println(node+" "+u);
				}else {
					dfs(u, node, vis, timer);
					System.out.println(node + " " + u);
				}
			}
		}
		int bfs(int v, int e, boolean[] vis) {
			int sum = 1;
			Queue<Integer> q = new LinkedList<>();
			q.add(v);
			vis[v] = true;
			while (q.size() > 0) {
				int n = q.size();
				for(int i=0;i<n;i++){
					int node = q.poll();
					for (int u : adj[node]) {
						if (!vis[u]) {
							if(u==e){
								return sum;
							}
							vis[u] = true;
							q.add(u);
						}
					}
				}
				sum++;
			}
			return sum;
		}

		public void dfs(boolean[] vis, int node, int par) {
			vis[node] = true;
			in[node] = low[node] = timer++;
			for(int u: adj[node]){
				if(u==par) continue;;
				if(vis[u]){
					low[node] = Math.min(low[node], in[u]);
					if(in[node]>in[u]){
						ans.add(new Pair<>(node, u));
					}
				}else {
					dfs(vis, u, node);
					if(low[u]>in[node]) {
						bridges++;
						if(bridges>0)return;
					}
					ans.add(new Pair<>(node, u));
					low[node] = Math.min(low[node], low[u]);
				}
			}
		}
	}

	static class Pair<F, S> {
		F first;
		S second;

		Pair(F first, S second) {
			this.first = first;
			this.second = second;
		}

		public F getFirst() {
			return this.first;
		}

		public S getSecond() {
			return this.second;
		}
		// Sort on basis of first term, reverse p1.first and p2.first to sort in desc
		// Collections.sort(a, (p1, p2) -> (p1.first - p2.first));

		// Sort on the basis of second term, reverse p1.second and p2.second to sort
		// in
		// desc
		// Collections.sort(a, (p1, p2) -> (p1.second - p2.second));
	}

	static long __gcd(long a, long b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);
	}

	public static int timer, bridges;
	public static int[] in, low;
	static ArrayList<Pair<Integer, Integer>> ans;
	private static HashMap<Integer, Integer> getHash(int[] a){
		HashMap<Integer, Integer> hm = new HashMap<>();
		for(int i: a){
			hm.put(i, hm.getOrDefault(i,0)+1);
		}
		return hm;
	}

	public static void main(String[] args) throws IOException {
		FastScanner fs = new FastScanner();
//		int t = fs.nextInt();
		int t = 1;
		StringBuffer res = new StringBuffer();
		for (int tt = 1; tt <= t; tt++) {
			int n = fs.nextInt();
			int m = fs.nextInt();
			Graph graph = new Graph(n);
			for(int i=0;i<m;i++){
				graph.addEdges(fs.nextInt(), fs.nextInt());
			}
			boolean[] vis = new boolean[n+1];
			in = new int[n+1];
			low = new int[n+1];
			timer = 0;
			bridges = 0;
			ans = new ArrayList<>();
			graph.dfs(vis, 1, -1);
			if(bridges>0){
				res.append(0);
			}else{
				for(Pair<Integer, Integer> p: ans){
					res.append(p.first).append(" ").append(p.second).append("\n");
				}
			}
		}
		System.out.println(res);
	}

	private static boolean check(long i) {
		long sum = 0, temp = i;
		while (temp>0){
			long r = temp%10;
			sum+=r;
			temp /= 10;
		}
		return __gcd(i, sum)>1;
	}

	private static boolean condition(int mid, int n, int[] a, int k, int[] pre) {
		return false;
	}
}