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.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.*;

public class Solution {
    private static final long mod = 998244353;
    static short dp[][];
    static HashMap<Integer,ArrayList<Integer>> map ;
    static HashMap<Integer,String> hm;
    static int n;
    static double ans;

    public static void main(String args[]) throws Exception {

        FastScanner sc = new FastScanner();

        int t;
        t = 1;//sc.nextInt();
        PrintWriter out = new PrintWriter(System.out);

        while (t-- > 0) {
            solve(sc, out);
        }
        out.close();


    }

    public static void solve(FastScanner sc, PrintWriter out) {
            int n = sc.nextInt();
            ArrayList<Integer> al[] = new ArrayList[n+1];
            getEdges(al, n, sc);
            ans = 0;
            dfs(al,1,0,0,1);
            out.println(ans);
            out.flush();
    }

    public static void dfs(ArrayList<Integer> al[],int node, int parent,int length, double probability ){
        if(al[node].size() == 1 && al[node].get(0) == parent){
            ans = ans + length * probability;
        }
        int count = al[node].size() - (node == 1 ? 0 : 1);
        probability = probability * (1 / (double)count);
        for(int child : al[node]){
            if(child == parent) continue;
            dfs(al,child, node, length + 1,probability);
        }
        return;

    }

    static void getEdges(ArrayList<Integer> al[], int n, FastScanner sc){
        for(int i = 1;i<=n;i++)
            al[i] = new ArrayList<>();
        for(int i = 1;i<=n-1;i++){
            int x = sc.nextInt(); int y = sc.nextInt();
            al[x].add(y);
            al[y].add(x);
        }
    }


    static int countCharactersInString(String s, char ch){
        int count = 0;
        for(char c : s.toCharArray()){
            if(c == ch) count++;
        }
        return count;
    }

    public static long pow(long a, long n, long mod){
        if(n == 0) return 1;
        else if(n%2 == 0){
            return pow((a*a)%mod,n/2,mod)%mod;
        }
        else return (pow((a*a)%mod,n/2,mod)%mod * a)%mod;
    }

    public static long modInverseCoPrime(long n, long mod){
        return pow(n,mod-2,mod);
    }

    static long modInverse(long A, long M)
    {
        extendedEuclid(A,M);
        return (x%M+M)%M;    //x may be negative
    }

    static long d, x, y;
    static void extendedEuclid(long A, long B) {
        if(B == 0) {
            d = A;
            x = 1;
            y = 0;
        }
        else {
            extendedEuclid(B, A%B);
            long temp = x;
            x = y;
            y = temp - (A/B)*y;
        }
    }

    public static boolean recurse(ArrayList<Integer> ans, int i, int k, ArrayList<String> in){
    if (i == n) {
      if (k == 0) return true;
      return false;
          }
        if(k < 0) return false;

        if(dp[i][k] != 0) return dp[i][k] == 1? true: false;

        int valid = -1;
        String input = in.get(i);
        ArrayList<Pair> p = getNumbers(input);
        boolean check = false;
        for(Pair element : p){
            if(recurse(ans,i+1,k-element.y,in)){
                valid = Math.max(valid, element.x);
                check = true;
                break;
            }
        }


        if(check){ dp[i][k] = 1;ans.add(valid);}
        else dp[i][k] = 2;
        return check;

    }

    public static ArrayList<Pair> getNumbers(String a){
        ArrayList<Pair> ans = new ArrayList<>();


        for (int i = 9; i >=0; i--) {
            int count = 0;
            boolean check = true;
            String b = hm.get(i);
            for (int j = 0; j < a.length(); j++) {
                if (a.charAt(j) == '1' && b.charAt(j) != '1') {check = false; break;}
                if (a.charAt(j) == '0' && b.charAt(j) == '1') count++;
            }

        if (check)
            ans.add(Pair.of(i,count));

        }

        return ans;
    }


    public static  <T> void clear(HashMap<Integer,ArrayList<T>> hm){
        for(int key : hm.keySet())
            hm.put(key, new ArrayList<>());
    }

    public static  <T> void fill(HashMap<Integer,ArrayList<T>> hm, int m){
        for(int i = 1;i<=m;i++)
            hm.put(i, new ArrayList<>());
    }



    static long calcChanges(long[] a, long val, int n, long k){
        long ans = 0;
        for(int i = 1;i<=n/2;i++){
            long x = a[i];
            long y = a[n-i-1];
            if((k + x < val && k + y < val) || ( 1 + x > val && 1 + y > val)){
                ans = ans + 2;
            } else if(x + y != val) ans = ans + 1;
        }
        return ans;
    }


    public static class Pair{
        int x;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Pair)) return false;
            Pair pair = (Pair) o;
            return x == pair.x &&
                    y == pair.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }

        int y;
        public static Pair of(int x, int y){
            Pair p = new Pair();
            p.x = x;
            p.y = y;
            return p;
        }
    }



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

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



class DFS{


    public void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        Graph g = new Graph();
        for(int i = 1;i<=n;i++)
            g.addNode(i);

        int e = sc.nextInt();
        while(e-->0){
            int one = sc.nextInt();
            int two = sc.nextInt();
            g.addEdge(one, two);
            g.addEdge(two, one);
        }
        g.resetVisited();
        g.DFS(g.nodes.get(1));


    }
}


class Node{
    int label;
    long touristP;
    long sum;
    Node parent;
    boolean visited = false;
    Node(int l){
        label=l;
        sum = 0;
        touristP = 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Node)) return false;
        Node node = (Node) o;
        return label == node.label &&
                touristP == node.touristP &&
                sum == node.sum &&
                visited == node.visited;
    }

    @Override
    public int hashCode() {
        return Objects.hash(label);
    }
}

class Graph{

    HashMap<Node,ArrayList<Node>> hm = new HashMap<>();
    HashMap<Integer,Node> nodes = new HashMap<>();
    Graph(){

    }

    void addNode(int n){
        Node node= new Node(n);
        this.nodes.put(n,node);
    }

    void addEdge(int f,int t){
        Node from = nodes.get(f);
        Node to = nodes.get(t);
        if(!hm.containsKey(from))
            hm.put(from,new ArrayList<>());

        hm.get(from).add(to);
    }

    void resetVisited(){
        for(Node n : hm.keySet()){
            n.visited = false;
            for(Node nn:hm.get(n))
                nn.visited = false;
        }
    }

    void DFS(Node n){
        if(n.visited)
            return;

        n.visited = true;
        System.out.print(n.label + " ");
        if(hm.containsKey(n))
            for(Node an : hm.get(n))
                DFS(an);
    }


    long DFSSum(Node n){
        if(n.visited)
            return 0l;

        n.visited = true;
        if(hm.containsKey(n)) {
            for (Node an : hm.get(n)) {
                n.sum = n.sum + DFSSum(an);

            }
        }

        return n.sum+1;
    }

    void BFS(Node n){
        Queue<Node> q = new LinkedList<>();
        q.add(n);

        while(!q.isEmpty()){
            Node node = q.poll();

            System.out.print(node.label+" ");
            node.visited = true;

            if(!hm.containsKey(node))
                continue;

            for(Node nn: hm.get(node)){
                if(nn.visited == false)
                {
                    if(!nn.visited)
                        q.add(nn);
                }
            }
        }

    }
}