JerryL/AlgoSimBench huggingface dataset:
1059_D. Nature Reserve

There is a forest that we model as a plane and live n rare animals. Animal number i has its lair in the point (x_{i}, y_{i}). In order to protect them, a decision to build a nature reserve has been made.

The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the forest. All animals drink from this river, therefore it must have at least one common point with the reserve. On the other hand, ships constantly sail along the river, so the reserve must not have more than one common point with the river.

For convenience, scientists have made a transformation of coordinates so that the river is defined by y = 0. Check whether it is possible to build a reserve, and if possible, find the minimum possible radius of such a reserve.

Input

The first line contains one integer n (1 ≤ n ≤ 10^5) — the number of animals. 

Each of the next n lines contains two integers x_{i}, y_{i} (-10^7 ≤ x_{i}, y_{i} ≤ 10^7) — the coordinates of the i-th animal's lair. It is guaranteed that y_{i} ≠ 0. No two lairs coincide.

Output

If the reserve cannot be built, print -1. Otherwise print the minimum radius. Your answer will be accepted if absolute or relative error does not exceed 10^{-6}.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.

Examples

Input

1
0 1


Output

0.5

Input

3
0 1
0 2
0 -3


Output

-1


Input

2
0 1
1 1


Output

0.625

Note

In the first sample it is optimal to build the reserve with the radius equal to 0.5 and the center in (0,\ 0.5).

In the second sample it is impossible to build a reserve.

In the third sample it is optimal to build the reserve with the radius equal to 5/8 and the center in (1/2,\ 5/8).

Example input:
2
0 1
1 1

1
0 1

3
0 1
0 2
0 -3


Example output:
0.624999999750000000077378853325

0.499999999874999999984479318038

-1


Tags: binary search
geometry
ternary search
Difficulty rating: 2200

Solution:
def check(mid):
    mx=0
    for i in range(n):
        mx=max(mx,(x[i]-mid)**2/(2*y[i])+(y[i]/2))
    return mx

n=int(input())
l=-100000000
r= 100000000
x=[]
y=[]
c1,c2=0,0
for i in range(n):
    a,b=map(int,input().split())
    if b>=0:
        c1+=1
    else:
        c2+=1
        
    
    x.append(a)
    y.append(abs(b))
if c1 and c2:
    print(-1)
    exit()
for i in range(100):
    m1=l+(r-l)/3
    m2=r-(r-l)/3
    if check(m1)>check(m2):
        l=m1
    else:
        r=m2
print(check(l))
106_E. Space Rescuers

The Galaxy contains n planets, there are many different living creatures inhabiting each planet. And each creature can get into troubles! Space rescuers know it perfectly well and they are always ready to help anyone who really needs help. All you need to do is call for them. 

Now the space rescuers plan to build the largest in the history of the Galaxy rescue station; however, the rescue station's location is yet to be determined. As some cases are real emergencies, the rescuers want to find such a point in the Galaxy from which it would be possible to get to the remotest planet in the minimum possible time. In other words, the rescuers need such point in the space that the distance between it and the planet remotest from it was minimal (if we compare this point with all other possible points in the space). Unfortunately, the rescuers can't sole this problem.

As the planets are quite remote from each other, they can be considered as points in Euclidean three-dimensional space. The distance between points (xi, yi, zi) and (xj, yj, zj) can be calculated by the formula <image>. The rescue station can be positioned in any point in the space. It can also coincide with some planet. 

Galaxy is in danger! Save the space rescuers and find the required point for them.

Input

The first line of the input file contains integer n — the number of planets (1 ≤ N ≤ 100). Each of the following n lines contains information about the planets. The i-th line contains three integers xi, yi, zi — the coordinates of the i-th planet ( - 104 ≤ xi, yi, zi ≤ 104, 1 ≤ i ≤ n). No two planets coincide.

Output

Print on the first line of the output file three space-separated real numbers x0, y0, z0 — the coordinates for the future base. If there are several solutions, you are allowed to print any of them. The answer will be accepted if the distance from this point to the remotest planet will differ from the juries' variant in no more than 10 - 6 in absolute or relative value.

Examples

Input

5
5 0 0
-5 0 0
0 3 4
4 -3 0
2 2 -2


Output

0.000 0.000 0.000

Example input:
5
5 0 0
-5 0 0
0 3 4
4 -3 0
2 2 -2


Example output:
-0.0000000666 0.0000000000 0.0000000000


Tags: geometry
ternary search
Difficulty rating: 2100

Solution:
#include <bits/stdc++.h>
using namespace std;
double x[150], y[150], z[150], a = 0, b = 0, c = 0;
double dist(double x, double y, double z) { return x * x + y * y + z * z; }
int main() {
  int i, n, ij, j;
  double bit = 1, t, temp;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i];
  for (i = 1; i <= 50000; i++) {
    t = -1;
    ij = 0;
    for (j = 1; j <= n; j++) {
      temp = dist(x[j] - a, y[j] - b, z[j] - c);
      if (temp > t) {
        t = temp;
        ij = j;
      }
    }
    a += bit * (x[ij] - a);
    b += bit * (y[ij] - b);
    c += bit * (z[ij] - c);
    bit *= 0.998;
  }
  printf("%.10f %.10f %.10f\n", a, b, c);
}
1095_C. Powers Of Two

A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....

You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.

Input

The only line of the input contains two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2 ⋅ 10^5).

Output

If it is impossible to represent n as the sum of k powers of two, print NO.

Otherwise, print YES, and then print k positive integers b_1, b_2, ..., b_k such that each of b_i is a power of two, and ∑ _{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.

Examples

Input


9 4


Output


YES
1 2 2 4 


Input


8 1


Output


YES
8 


Input


5 1


Output


NO


Input


3 7


Output


NO

Example input:
8 1

5 1

9 4

3 7


Example output:
YES
8

NO

YES
1 2 2 4

NO


Tags: bitmasks
greedy
Difficulty rating: 1400

Solution:
n,k=map(int,input().split())
a=[1]*k
n-=k
i=0
while i<k and n:
 while a[i]<=n:n-=a[i];a[i]*=2
 i+=1
if n:print('NO')
else:print('YES',*a)
1097_G. Vladislav and a Great Legend

A great legend used to be here, but some troll hacked Codeforces and erased it. Too bad for us, but in the troll society he earned a title of an ultimate-greatest-over troll. At least for them, it's something good. And maybe a formal statement will be even better for us?

You are given a tree T with n vertices numbered from 1 to n. For every non-empty subset X of vertices of T, let f(X) be the minimum number of edges in the smallest connected subtree of T which contains every vertex from X.

You're also given an integer k. You need to compute the sum of (f(X))^k among all non-empty subsets of vertices, that is:

$$$ ∑_{X ⊆ \{1, 2,\: ... \:, n\},  X ≠ ∅} (f(X))^k. $$$

As the result might be very large, output it modulo 10^9 + 7.

Input

The first line contains two integers n and k (2 ≤ n ≤ 10^5, 1 ≤ k ≤ 200) — the size of the tree and the exponent in the sum above.

Each of the following n - 1 lines contains two integers a_i and b_i (1 ≤ a_i,b_i ≤ n) — the indices of the vertices connected by the corresponding edge.

It is guaranteed, that the edges form a tree.

Output

Print a single integer — the requested sum modulo 10^9 + 7.

Examples

Input


4 1
1 2
2 3
2 4


Output


21


Input


4 2
1 2
2 3
2 4


Output


45


Input


5 3
1 2
2 3
3 4
4 5


Output


780

Note

In the first two examples, the values of f are as follows:

f(\{1\}) = 0

f(\{2\}) = 0

f(\{1, 2\}) = 1

f(\{3\}) = 0

f(\{1, 3\}) = 2

f(\{2, 3\}) = 1

f(\{1, 2, 3\}) = 2

f(\{4\}) = 0

f(\{1, 4\}) = 2

f(\{2, 4\}) = 1

f(\{1, 2, 4\}) = 2

f(\{3, 4\}) = 2

f(\{1, 3, 4\}) = 3

f(\{2, 3, 4\}) = 2

f(\{1, 2, 3, 4\}) = 3

Example input:
4 1
1 2
2 3
2 4

4 2
1 2
2 3
2 4

5 3
1 2
2 3
3 4
4 5


Example output:
21

45

780


Tags: combinatorics
dp
trees
Difficulty rating: 3000

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, K = 205, P = 1e9 + 7;
int n, k, ans, S[K][K], f[N][K], g[N], sz[N], res[N];
vector<int> G[N];
void dp(int u, int fa) {
  sz[u] = 1, f[u][0] = 2;
  for (int v : G[u])
    if (v != fa) {
      dp(v, u), memset(g, 0, sizeof(int[k + 1]));
      for (int i = 0; i <= min(sz[u], k); ++i)
        for (int j = 0; j <= min(sz[v], k - i); ++j)
          (g[i + j] += 1LL * f[u][i] * f[v][j] % P) %= P;
      for (int i = 0; i <= k; ++i) f[u][i] = g[i], (res[i] += P - f[v][i]) %= P;
      sz[u] += sz[v];
    }
  for (int i = 0; i <= k; ++i) (res[i] += f[u][i]) %= P;
  for (int i = k; i; --i) (f[u][i] += f[u][i - 1]) %= P;
  --f[u][1];
}
int main() {
  scanf("%d%d", &n, &k), S[0][0] = 1;
  for (int i = 1; i <= k; ++i)
    for (int j = 1; j <= k; ++j)
      S[i][j] = (S[i - 1][j - 1] + 1LL * j * S[i - 1][j] % P) % P;
  for (int i = 1, a, b; i < n; ++i)
    scanf("%d%d", &a, &b), G[a].push_back(b), G[b].push_back(a);
  dp(1, 0);
  for (int i = 0, fc = 1; i <= k; ++i, fc = 1LL * fc * i % P)
    (ans += 1LL * S[k][i] * fc % P * res[i] % P) %= P;
  printf("%d", ans);
  return 0;
}
109_B. Lucky Probability

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya and his friend Vasya play an interesting game. Petya randomly chooses an integer p from the interval [pl, pr] and Vasya chooses an integer v from the interval [vl, vr] (also randomly). Both players choose their integers equiprobably. Find the probability that the interval [min(v, p), max(v, p)] contains exactly k lucky numbers.

Input

The single line contains five integers pl, pr, vl, vr and k (1 ≤ pl ≤ pr ≤ 109, 1 ≤ vl ≤ vr ≤ 109, 1 ≤ k ≤ 1000).

Output

On the single line print the result with an absolute error of no more than 10 - 9.

Examples

Input

1 10 1 10 2


Output

0.320000000000


Input

5 6 8 10 1


Output

1.000000000000

Note

Consider that [a, b] denotes an interval of integers; this interval includes the boundaries. That is, <image>

In first case there are 32 suitable pairs: (1, 7), (1, 8), (1, 9), (1, 10), (2, 7), (2, 8), (2, 9), (2, 10), (3, 7), (3, 8), (3, 9), (3, 10), (4, 7), (4, 8), (4, 9), (4, 10), (7, 1), (7, 2), (7, 3), (7, 4), (8, 1), (8, 2), (8, 3), (8, 4), (9, 1), (9, 2), (9, 3), (9, 4), (10, 1), (10, 2), (10, 3), (10, 4). Total number of possible pairs is 10·10 = 100, so answer is 32 / 100.

In second case Petya always get number less than Vasya and the only lucky 7 is between this numbers, so there will be always 1 lucky number.

Example input:
1 10 1 10 2

5 6 8 10 1


Example output:
0.32000000000000000666
1

Tags: brute force
probabilities
Difficulty rating: 1900

Solution:
pl,pr,vl,vr,k = map(int,raw_input().split())
p,x = [0,1e9],0
def g(x):
    if x<1e9:
        p.append(x)
        g(10*x+4),g(10*x+7)
g(4),g(7),p.sort()
def f(a,b,c,d): return max(0,min(b,d)-max(a,c)+1)
for i in range(1,len(p)-k):
    q,r,s,t=p[i-1]+1,p[i],p[i+k-1],p[i+k]-1
    x+=f(q,r,vl,vr)*f(s,t,pl,pr)+f(q,r,pl,pr)*f(s,t,vl,vr)
    if k==1 and r>=max(vl,pl) and r<=min(vr,pr): x-=1
print(1.*x/((pr-pl+1)*(vr-vl+1)))
1110_E. Magic Stones

Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i.

Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≤ i ≤ n - 1), and after that synchronizes it with neighboring stones. After that, the chosen stone loses its own charge, but acquires the charges from neighboring stones. In other words, its charge c_i changes to c_i' = c_{i + 1} + c_{i - 1} - c_i.

Andrew, Grigory's friend, also has n stones with charges t_i. Grigory is curious, whether there exists a sequence of zero or more synchronization operations, which transforms charges of Grigory's stones into charges of corresponding Andrew's stones, that is, changes c_i into t_i for all i?

Input

The first line contains one integer n (2 ≤ n ≤ 10^5) — the number of magic stones.

The second line contains integers c_1, c_2, …, c_n (0 ≤ c_i ≤ 2 ⋅ 10^9) — the charges of Grigory's stones.

The second line contains integers t_1, t_2, …, t_n (0 ≤ t_i ≤ 2 ⋅ 10^9) — the charges of Andrew's stones.

Output

If there exists a (possibly empty) sequence of synchronization operations, which changes all charges to the required ones, print "Yes".

Otherwise, print "No".

Examples

Input


4
7 2 4 12
7 15 10 12


Output


Yes


Input


3
4 4 4
1 2 3


Output


No

Note

In the first example, we can perform the following synchronizations (1-indexed):

  * First, synchronize the third stone [7, 2, 4, 12] → [7, 2, 10, 12]. 
  * Then synchronize the second stone: [7, 2, 10, 12] → [7, 15, 10, 12]. 



In the second example, any operation with the second stone will not change its charge.

Example input:
4
7 2 4 12
7 15 10 12

3
4 4 4
1 2 3


Example output:
Yes

No


Tags: constructive algorithms
math
sortings
Difficulty rating: 2200

Solution:
n=int(input())
y=lambda l:sorted(list(l[i+1]-l[i]for i in range(len(l)-1)))
z=lambda:list(map(int,input().split()))
c=z()
t=z()
print(['No','Yes'][c[0]==t[0]and y(c)==y(t)])
1151_B. Dima and a Bad XOR

Student Dima from Kremland has a matrix a of size n × m filled with non-negative integers.

He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him!

Formally, he wants to choose an integers sequence c_1, c_2, …, c_n (1 ≤ c_j ≤ m) so that the inequality a_{1, c_1} ⊕ a_{2, c_2} ⊕ … ⊕ a_{n, c_n} > 0 holds, where a_{i, j} is the matrix element from the i-th row and the j-th column.

Here x ⊕ y denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 500) — the number of rows and the number of columns in the matrix a.

Each of the next n lines contains m integers: the j-th integer in the i-th line is the j-th element of the i-th row of the matrix a, i.e. a_{i, j} (0 ≤ a_{i, j} ≤ 1023). 

Output

If there is no way to choose one integer from each row so that their bitwise exclusive OR is strictly greater than zero, print "NIE".

Otherwise print "TAK" in the first line, in the next line print n integers c_1, c_2, … c_n (1 ≤ c_j ≤ m), so that the inequality a_{1, c_1} ⊕ a_{2, c_2} ⊕ … ⊕ a_{n, c_n} > 0 holds. 

If there is more than one possible answer, you may output any.

Examples

Input


3 2
0 0
0 0
0 0


Output


NIE


Input


2 3
7 7 7
7 7 10


Output


TAK
1 3 

Note

In the first example, all the numbers in the matrix are 0, so it is impossible to select one number in each row of the table so that their bitwise exclusive OR is strictly greater than zero.

In the second example, the selected numbers are 7 (the first number in the first line) and 10 (the third number in the second line), 7 ⊕ 10 = 13, 13 is more than 0, so the answer is found.

Example input:
3 2
0 0
0 0
0 0

2 3
7 7 7
7 7 10


Example output:
NIE
TAK
1 3 

Tags: bitmasks
brute force
constructive algorithms
dp
Difficulty rating: 1600

Solution:
R=lambda:map(int,input().split())
n,m=R()
a=[]
s=i=0
t=[1]*n
for _ in t:r=*R(),;a+=r,;s^=r[0]
for r in a:
 j=0
 for x in r:
  if s^r[0]^x:t[i]+=j;print('TAK',*t);exit()
  j+=1
 i+=1
print('NIE')
1155_E. Guess the Root

Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0.

Now jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0.

You can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3).

Note that printing the answer doesn't count as a query.

Interaction

To ask a question, print "? x_q" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts.

After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: 

  * fflush(stdout) or cout.flush() in C++; 
  * System.out.flush() in Java; 
  * flush(output) in Pascal; 
  * stdout.flush() in Python; 
  * see documentation for other languages. 



When you are ready to answer, print "! x_0" where x_0 is the answer or -1 if there is no such x_0.

You can ask at most 50 questions per test case.

Hack Format

To hack, use the following format.

The only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial.

Examples

Input


 
1000002

0


Output


? 0

? 1

! 1

Input


 
5

2

1



Output


? 2

? 1

? 0

! -1

Note

The polynomial in the first sample is 1000002 + x^2.

The polynomial in the second sample is 1 + x^2.

Example input:
5

2

1


1000002

0


Example output:
? 0
? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
! 3

? 0
? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
! 1

Tags: brute force
interactive
math
Difficulty rating: 2200

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MD = 20;
const long long MOD = 1000003;
int main() {
  long long n;
  vector<long long> v(MD);
  vector<vector<long long> > a;
  for (int i = 0; i < MD; i++) {
    cout << "? " << i << endl << flush;
    cin >> v[i];
    if (v[i] == 0) {
      cout << "! " << i << endl;
      exit(0);
    }
  }
  a.push_back(v);
  vector<long long> empty;
  for (int i = 1; i < MD; i++) {
    a.push_back(empty);
    for (int j = 0; j + 1 < a[i - 1].size(); j++)
      a[i].push_back((a[i - 1][j + 1] - a[i - 1][j] + MOD) % MOD);
  }
  vector<long long> w;
  for (int i = 0; i < MD; i++) w.push_back(a[i][MD - i - 1]);
  for (int i = MD; i < MOD; i++) {
    for (int j = w.size() - 2; j >= 0; j--) w[j] = (w[j] + w[j + 1]) % MOD;
    if (w[0] == 0) {
      cout << "! " << i << endl;
      exit(0);
    }
  }
  cout << "! " << -1 << endl;
}
1163_E. Magical Permutation

Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen n distinct positive integers and put all of them in a set S. Now he defines a magical permutation to be:

  * A permutation of integers from 0 to 2^x - 1, where x is a non-negative integer. 
  * The [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of any two consecutive elements in the permutation is an element in S.



Since Kuro is really excited about magical permutations, he wants to create the longest magical permutation possible. In other words, he wants to find the largest non-negative integer x such that there is a magical permutation of integers from 0 to 2^x - 1. Since he is a newbie in the subject, he wants you to help him find this value of x and also the magical permutation for that x.

Input

The first line contains the integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in the set S.

The next line contains n distinct integers S_1, S_2, …, S_n (1 ≤ S_i ≤ 2 ⋅ 10^5) — the elements in the set S.

Output

In the first line print the largest non-negative integer x, such that there is a magical permutation of integers from 0 to 2^x - 1.

Then print 2^x integers describing a magical permutation of integers from 0 to 2^x - 1. If there are multiple such magical permutations, print any of them.

Examples

Input


3
1 2 3


Output


2
0 1 3 2 

Input


2
2 3


Output


2
0 2 1 3 

Input


4
1 2 3 4


Output


3
0 1 3 2 6 7 5 4 

Input


2
2 4


Output


0
0 

Input


1
20


Output


0
0 

Input


1
1


Output


1
0 1 

Note

In the first example, 0, 1, 3, 2 is a magical permutation since:

  * 0 ⊕ 1 = 1 ∈ S 
  * 1 ⊕ 3 = 2 ∈ S 
  * 3 ⊕ 2 = 1 ∈ S



Where ⊕ denotes [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation.

Example input:
1
1

1
20

2
2 4

3
1 2 3

2
2 3

4
1 2 3 4


Example output:
1
0 1 
0 
0
0 
0
2
0 1 3 2 
2
0 2 1 3 
3
0 1 3 2 6 7 5 4 

Tags: bitmasks
brute force
constructive algorithms
data structures
graphs
math
Difficulty rating: 2400

Solution:
#include <bits/stdc++.h>
using namespace std;
int a[1 << 19], ans[1 << 19], base[20], val[20];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int s = 0, cnt = 0;
  for (int i = 1, j = 1; i < 20; i++) {
    for (; j <= n && a[j] < 1 << i; j++) {
      int x = a[j];
      for (int k = 19; ~k; k--)
        if (x & 1 << k) {
          if (!base[k]) cnt++, base[k] = x, val[k] = a[j];
          x ^= base[k];
        }
    }
    if (cnt == i) s = i;
  }
  cout << s << endl;
  cout << (ans[0] = 0);
  for (int i = 0; i < s; i++)
    for (int j = 0; j < 1 << i; j++)
      cout << ' ' << (ans[j ^ 1 << i] = ans[(1 << i) - 1 ^ j] ^ val[i]);
  return 0;
}
118_E. Bertown roads

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

Example input:
6 7
1 2
2 3
1 3
4 5
4 6
5 6
2 4

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


Example output:
0

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


Tags: dfs and similar
graphs
Difficulty rating: 2000

Solution:
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
vector<pair<int, int> > ans;
int disc[100005], low[100005], t;
void dfs(int node, int p) {
  disc[node] = ++t;
  low[node] = disc[node];
  for (int u : v[node]) {
    if (u == p) continue;
    if (!disc[u]) {
      ans.push_back({node, u});
      dfs(u, node);
      low[node] = min(low[node], low[u]);
    } else
      low[node] = min(low[node], disc[u]);
    if (disc[u] < disc[node]) ans.push_back({node, u});
    if (low[u] > disc[node]) {
      printf("0");
      exit(0);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0);
  for (auto i : ans) printf("%d %d\n", i.first, i.second);
}