Problem: There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.

Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But the weather is foggy, so they can’t see where the horse brings them. When the horse reaches a city (including the first one), it goes to one of the cities connected to the current city. But it is a strange horse, it only goes to cities in which they weren't before. In each such city, the horse goes with equal probabilities and it stops when there are no such cities. 

Let the length of each road be 1. The journey starts in the city 1. What is the expected length (expected value of length) of their journey? You can read about expected (average) value by the link <https://en.wikipedia.org/wiki/Expected_value>.

Input

The first line contains a single integer n (1 ≤ n ≤ 100000) — number of cities.

Then n - 1 lines follow. The i-th line of these lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the cities connected by the i-th road.

It is guaranteed that one can reach any city from any other by the roads.

Output

Print a number — the expected length of their journey. The journey starts in the city 1.

Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Examples

Input

4
1 2
1 3
2 4


Output

1.500000000000000


Input

5
1 2
1 3
3 4
2 5


Output

2.000000000000000

Note

In the first sample, their journey may end in cities 3 or 4 with equal probability. The distance to city 3 is 1 and to city 4 is 2, so the expected length is 1.5.

In the second sample, their journey may end in city 4 or 5. The distance to the both cities is 2, so the expected length is 2.

Solution (in JAVA):

Solution:


import java.util.*;



import java.io.*;
import java.lang.*;
import java.security.KeyStore.Entry;
public class Main {

static ArrayList<Integer> aj[];



void solve()
  {
   in=new InputReader(System.in);
   w=new PrintWriter(System.out);
 
         int n=in.nextInt();
           aj=new ArrayList[n+1];
          for(int i=1;i<=n;i++)
              aj[i]=new ArrayList<Integer>();
          for(int i=0;i<n-1;i++)
             {
             int u=in.nextInt();
             int v=in.nextInt();

             aj[u].add(v);
             aj[v].add(u);
}
w.println((double)dfs(1,0));
w.close();

}

public static void main(String[] args) throws IOException
{
        new Main().solve();
}

double dfs(int c,int p)
  {
       double ans=0;
       double s=0;

        for(int i:aj[c])
         {
            if(i!=p)
            {
              ans+=1+dfs(i,c);
              s++;
            }
         }
      if(s!=0)
         ans=ans/s; 
      return ans;
  }


public static class dsu
{

int n;
int parent[];
int s[];
dsu(int n)
{
this.n=n;
parent=new int[n+1];
s=new int[n+1];
for(int i=0;i<=n;i++)
{
parent[i]=i;
s[i]=1;
}
}
int find(int i)
{
if (parent[i] == i)
return i;
else
{
int result = find(parent[i]);
parent[i] = result;
return result;
}
}
}
static InputReader in;
static PrintWriter w;
public boolean oj = System.getProperty("ONLINE_JUDGE") != null;

public void tr(Object... o) {
if (!oj)
System.out.println(Arrays.deepToString(o));
}


public static long power(long a,long b,long c)
{
long ans = 1;
while(b!=0)
{
if(b%2==1)
{
ans = ans*a;
ans = ans % c;
}
a = a*a;
a = a%c;
b = b/2;
}
return ans;
}
static class Pair implements Comparable<Pair> {
int cno;
int cs;
int cc;
public Pair(){

}
public Pair(int u,int v,int i) {
this.cno=u;
this.cs=v;
this.cc=i;
}

public int compareTo(Pair other) {

return 0;
}

/*public String toString() {
return "[u=" + u + ", v=" + v + "]";
}*/
}
static class Node2{
Node2 left = null;
Node2 right = null;
Node2 parent = null;
int data;
}

//binaryStree
static class BinarySearchTree{
Node2 root = null;
int height = 0;
int max = 0;
int cnt = 1;
ArrayList<Integer> parent = new ArrayList<Integer>();
HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
public void insert(int x){
Node2 n = new Node2();
n.data = x;
if(root==null){
root = n;
}
else{
Node2 temp = root,temp2 = null;
while(temp!=null){
temp2 = temp;
if(x>temp.data) temp = temp.right;
else temp = temp.left;
}
if(x>temp2.data) temp2.right = n;
else temp2.left = n;
n.parent = temp2;
parent.add(temp2.data);
}
}
public Node2 getSomething(int x, int y, Node2 n){
if(n.data==x || n.data==y) return n;
else if(n.data>x && n.data<y) return n;
else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
else return getSomething(x,y,n.left);
}
public Node2 search(int x,Node2 n){
if(x==n.data){
max = Math.max(max, n.data);
return n;
}
if(x>n.data){
max = Math.max(max, n.data);
return search(x,n.right);
}
else{
max = Math.max(max, n.data);
return search(x,n.left);
}
}
public int getHeight(Node2 n){
if(n==null) return 0;
height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
return height;
}
}
public static void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}

public static String rev(String s)
{
StringBuilder sb=new StringBuilder(s);
sb.reverse();
return sb.toString();
}

static long lcm(long a, long b)
{
return a * (b / gcd(a, b));
}

static long gcd(long a, long b)
{
while (b > 0)
{
long temp = b;
b = a % b; // % is remainder
a = temp;
}
return a;
}

public static long max(long x, long y, long z){
if(x>=y && x>=z) return x;
if(y>=x && y>=z) return y;
return z;
}
static int[] sieve(int n,int[] arr)
{
for(int i=2;i*i<=n;i++)
{
if(arr[i]==0)
{
for(int j=i*2;j<=n;j+=i)
arr[j]=1;
}
}
return arr;
}




static class InputReader {

private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;

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

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

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

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

public int[] nextIntArray(int n) {
return nextIntArray(n, 0);
}

public int[] nextIntArray(int n, int off) {
int[] arr = new int[n + off];
for (int i = 0; i < n; i++) {
arr[i + off] = nextInt();
}
return arr;
}

public long[] nextLongArray(int n) {
return nextLongArray(n, 0);
}

public long[] nextLongArray(int n, int off) {
long[] arr = new long[n + off];
for (int i = 0; i < n; i++) {
arr[i + off] = nextLong();
}
return arr;
}


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

public String nextLine() {
int c = snext();
while (isSpaceChar(c))
c = snext();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = snext();
} while (!isEndOfLine(c));
return res.toString();
}

public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

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

public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}

}