Limak is a little grizzly bear. He will once attack Deerland but now he can only destroy trees in role-playing games. Limak starts with a tree with one vertex. The only vertex has index 1 and is a root of the tree.Sometimes, a game chooses a subtree and allows Limak to attack it. When a subtree is attacked then each of its edges is destroyed with probability , independently of other edges. Then, Limak gets the penalty — an integer equal to the height of the subtree after the attack. The height is defined as the maximum number of edges on the path between the root of the subtree and any vertex in the subtree.You must handle queries of two types.  1 v denotes a query of the first type. A new vertex appears and its parent is v. A new vertex has the next available index (so, new vertices will be numbered 2, 3, ...).  2 v denotes a query of the second type. For a moment let's assume that the game allows Limak to attack a subtree rooted in v. Then, what would be the expected value of the penalty Limak gets after the attack? In a query of the second type, Limak doesn't actually attack the subtree and thus the query doesn't affect next queries.

The first line of the input contains one integer q (1 ≤ q ≤ 500 000) — the number of queries. Then, q lines follow. The i-th of them contains two integers typei and vi (1 ≤ typei ≤ 2). If typei = 1 then vi denotes a parent of a new vertex, while if typei = 2 then you should print the answer for a subtree rooted in vi. It's guaranteed that there will be at least 1 query of the second type, that is, the output won't be empty. It's guaranteed that just before the i-th query a vertex vi already exists.

For each query of the second type print one real number —the expected value of the penalty if Limak attacks the given subtree. 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 .

NoteBelow, you can see the drawing for the first sample. Red circles denote queries of the second type.

#include <bits/stdc++.h>
using namespace std;
const int N = 500005,M = 60;
int q,fa[N],n = 1;
double dp[N][M + 5];
int main ()
{
    ios::sync_with_stdio(false);
    cin >> q;
    int opt,pos;
    for (int i = 0;i <= M;i++) dp[1][i] = 1;
    for (int _ = 1;_ <= q;_++)
    {
        cin >> opt >> pos;
        if (opt == 1)
        {
            fa[++n] = pos;
            for (int i = 0;i <= M;i++) dp[n][i] = 1;
            double pre = 1;int pp = n;
            for (int i = 0,cur = pos;cur && i <= M;i++,cur = fa[cur])
            {
                double tmp = dp[cur][i];
                dp[cur][i] /= 0.5 * (pre + 1);
                if (i) dp[cur][i] *= 0.5 * (1 + dp[pp][i - 1]);
                else dp[cur][i] *= 0.5;
                pp = cur;pre = tmp;
            }
        }
        else
        {
            double ans = 0;
            for (int i = 1;i <= M;i++)
                ans += (dp[pos][i] - dp[pos][i - 1]) * i;
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}
//一道需要忽略误差的题......//hellobig_tq//hello//hello

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int maxn=5e5+20;
double f[maxn][36];
int m,x,t,v;
int pr[maxn];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> m;
    v=1;
    cout.precision(10);
    for (int i=0;i<=35;i++) f[1][i]=1;
    for (int i=1;i<=m;i++) {
        cin >> t >> x;
        if (t==1) {
            v++;
            pr[v]=x;
            for (int j=0;j<=35;j++) f[v][j]=1;
            double prev=f[x][0];
            f[x][0]=f[x][0]*0.5;
            if (x!=1) {
                for (int j=1;j<=35;j++) {
                    int q=pr[x];
                    double cur=f[q][j];
                    f[q][j]=f[q][j]*(f[x][j-1]+1)/(prev+1);
                    prev=cur;
                    if (q==1) break;
                    x=q;
                }
            }
        }
        else {
            long double ans=0;
            for (int j=1;j<=35;j++) ans+=(f[x][j]-f[x][j-1])*j;
            cout << fixed << ans << "\n";
        }
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#pragma comment (linker, "/STACK:256000000")

using namespace std;

const int maxN = 510000;
const int maxK = 36;
const double eps = 1e-20;

vector < int > g[maxN];
int q;
int n = 1;
int parent[maxN];

double p[maxN][maxK];
double p2[maxN];

void initVertex(int v) {
	for (int i = 0; i < maxK; ++i) {
		p[v][i] = 1.0;
	}
}

void updateVertex(int v, int u, bool add) {
	for (int i = 1; i < maxK; ++i) {
		double value = 0.5 * (1.0 + p[u][i - 1]);
		if (add) {
			p[v][i] *= value;
		} else {
			p[v][i] /= value;
		}
		if (p[v][i] < eps) {
			p[v][i] = 0.0;
		}
	}

	if (add) {
		p[v][0] = p2[g[v].size()];
	}
}

void addVertex(int v) {
	++n;
	int u = n;

	parent[u] = v;
	g[v].push_back(u);

	int depth = 0;
	vector < int > path;
	path.push_back(u);
	while (v != 0 && depth < maxK) {
		++depth;
		path.push_back(v);
		v = parent[v];
	}

	reverse(path.begin(), path.end());

	for (int i = 0; i + 2 < path.size(); ++i) {
		updateVertex(path[i], path[i + 1], false);
	}

	initVertex(u);
	for (int i = (int)(path.size()) - 2; i >= 0; --i) {
		updateVertex(path[i], path[i + 1], true);
	}
}

double getRes(int v) {
	double res = 0.0;
	for (int i = 1; i < maxK; ++i) {
		double q = p[v][i] - p[v][i - 1];
		res += q * (double)(i);
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	p2[0] = 1.0;
	for (int i = 1; i < maxN; ++i) {
		p2[i] = p2[i - 1] * 0.5;
		if (p2[i] < eps) {
			p2[i] = 0.0;
		}
	}

	scanf("%d", &q);
	initVertex(1);
	for (int i = 0; i < q; ++i) {
		int mode, v;
		scanf("%d%d", &mode, &v);
		if (mode == 1) {
			addVertex(v);
		} else {
			printf("%.10lf\n", getRes(v));
		}
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define piii pair<pii, int>
#define vi vector<int>
#define vpii vector<pii>

#define read1(a) int a; scanf("%d", &a)
#define read2(a, b) int a, b; scanf("%d %d", &a, &b)
#define read3(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c)

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)

#define readgi(n) F0R(i, n) { scanf("%d", &arr[i]); }
#define readgs(n) F0R(i, n) { scanf(" %c", &arr[i]); }

#define f first
#define s second

#define usaco(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout);

#define println1(a) printf("%d\n", a);
#define println2(a, b) printf("%d %d\n", a, b);
#define println3(a, b, c) printf("%d %d %d\n", a, b, c);
#define pv(v) for (int i : v) { printf("%d ", i); } printf("\n");

const int MOD = 1000000007;
const int MAX = 3005;

double dp[500005][65];
double old[500005][65];
int par[500005];

int main() {
    dp[1][0] = 1;
    read1(q);
    int vetx = 2;
    F0R(query, q) {
        read2(x, y);
        if (x == 1) {
            par[vetx] = y;
            int st = vetx;
            dp[st][0] = 1;
            FOR(i, 1, 65) {
                if (st == 1) { break; }
                int parent = par[st];
                old[parent][i] = dp[parent][i];
                dp[parent][i] = 1 - (1 - dp[parent][i]) * (1 - 0.5*dp[st][i-1]) / (1 - 0.5*old[st][i-1]);
                st = parent;
            }
            vetx++;
        }
        if (x == 2) {
            double tot = 0;
            FOR(i, 1, 65) { tot += dp[y][i]; }
            cout << fixed << setprecision(10) << tot << endl;
        }
    }
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n = 100;
    ll q;
    cin >> q;
    vector<vector<double>> a((size_t) n + 1, vector<double>((size_t) q + 1, 1));
    vector<ll> b((size_t) q + 1, -1);
    for (ll t = 0, z = 1; t < q; t++) {
        ll x, y;
        cin >> x >> y;
        y--;
        if (x == 1) {
            vector<ll> c;
            for (ll i = y, j = 1; i != -1 && j <= n; i = b[i], j++) {
                c.push_back(i);
            }
            for (ll i = (ll) c.size() - 1; i >= 1; i--) {
                a[i][c[i]] /= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            b[z] = y;
            a[0][y] *= 0.5;
            for (ll i = 1; i < (ll) c.size(); i++) {
                a[i][c[i]] *= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            z++;
        }
        if (x == 2) {
            double j = 0;
            for (ll i = 0; i <= n; i++) {
                j += (a[i][y] - (i == 0 ? 0 : a[i - 1][y])) * i;
            }
            cout << setprecision(100) << j << "\n";
            cout.flush();
        }
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

#define N 500020
#define T 66
#define eps 1e-8

int n;
double dp[N][T];
int fa[N], d[N];

int main() {
	int q;
	scanf("%d", &q);
	n = 1;
	for(int i = 0; i < T; ++i) dp[1][i] = 1;

	while(q--) {
		int t, v;
		scanf("%d%d", &t, &v);
		if(t == 1) {
			++n;
			for(int i = 0; i < T; ++i) dp[n][i] = 1;
			fa[n] = v;
			d[v]++;
			double pre = dp[v][0];

			dp[v][0] = pow(0.5, d[v]);
			int k = 1;
			while(fa[v] && k < T) {
				int u = fa[v];
				double tmp = dp[u][k];
				dp[u][k] /= 0.5 + 0.5 * pre;
				dp[u][k] *= 0.5 + 0.5 * dp[v][k-1];
				pre = tmp;
				v = u;
				++k;
			}
		}
		else {
			double ans = 0;
			for(int i = 1; i < T; ++i) ans += i * (dp[v][i] - dp[v][i-1]);
			printf("%.12lf\n", ans);
		}
	}
	return 0;
}

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

#define MAXN 500010
#define MAXH 70

static int N = 1, Q, fa[MAXN], deg[MAXN];
static double dp[MAXN][MAXH];

int main()
{
    for (int i = 0; i < MAXH; i++) dp[N][i] = 1;
    scanf("%d", &Q);
    while (Q--)
    {
        int type, u; scanf("%d%d", &type, &u);
        if (type == 1)
        {
            deg[fa[++N] = u]++;
            for (int i = 0; i < MAXH; i++) dp[N][i] = 1;
            double tmp1 = dp[u][0], tmp2;
            dp[u][0] = pow(0.5, deg[u]);
            for (int i = 1; fa[u] && i < MAXH; i++, u = fa[u])
            {
                tmp2 = dp[fa[u]][i];
                dp[fa[u]][i] /= 0.5 + 0.5 * tmp1;
                dp[fa[u]][i] *= 0.5 + 0.5 * dp[u][i-1];
                tmp1 = tmp2;
            }
        }
        else
        {
            double ans = 0;
            for (int i = 1; i < MAXH; i++)
                ans += (dp[u][i] - dp[u][i-1]) * i;
            printf("%.12f\n", ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 500005,M = 60;
int q,fa[N],n = 1;
double dp[N][M + 5];
int main ()
{
    ios::sync_with_stdio(false);
    cin >> q;
    int opt,pos;
    for (int i = 0;i <= M;i++) dp[1][i] = 1;
    for (int _ = 1;_ <= q;_++)
    {
        cin >> opt >> pos;
        if (opt == 1)
        {
            fa[++n] = pos;
            for (int i = 0;i <= M;i++) dp[n][i] = 1;
            double pre = 1;int pp = n;
            for (int i = 0,cur = pos;cur && i <= M;i++,cur = fa[cur])
            {
                double tmp = dp[cur][i];
                dp[cur][i] /= 0.5 * (pre + 1);
                if (i) dp[cur][i] *= 0.5 * (1 + dp[pp][i - 1]);
                else dp[cur][i] *= 0.5;
                pp = cur;pre = tmp;
            }
        }
        else
        {
            double ans = 0;
            for (int i = 1;i <= M;i++)
                ans += (dp[pos][i] - dp[pos][i - 1]) * i;
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}
//一道需要忽略误差的题......//hellobig_tq

#include <bits/stdc++.h>
using namespace std;

const int MAXN=500005,MAXH=50;

int fa[MAXN];
double p[MAXN][MAXH];

int main()
{
	int q;
	scanf("%d",&q);
	int id=1;
	while (q--)
	{
		int op,v;
		scanf("%d%d",&op,&v);
		if (op==1)
		{
			fa[++id]=v;
			double t1=0,t2=1;
			for (int i=1,now=v;i<MAXH&&now;i++,now=fa[now])
			{
				double t=p[now][i];
				p[now][i]=1-(1-p[now][i])/(1-t1/2)*(1-t2/2);
				t1=t;
				t2=p[now][i];
			}
		}
		else
		{
			double ans=0;
			for (int i=1;i<MAXH;i++)
				ans+=p[v][i];
			printf("%.8f\n",ans);
		}
	}
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx")
#pragma GCC target ("avx2,fma")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define rank fewfewf
//#define double long double

using namespace std;
using namespace __gnu_pbds;

typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 500100;
const int K = 50;
const int mod = 1e9 + 7;
double p[N][K];
int d[N];
int a[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q;
    cin >> q;
    int n = 1;
    cout << fixed << setprecision(15);
    for (int i = 0; i < K; i++) p[1][i] = 1;
    while(q--){
        int type, v;
        cin >> type >> v;
        if (type == 1){
            n++;
            a[n] = v;
            d[v]++;
            for (int i = 0; i < K; i++) p[n][i] = 1;
            int k = 0;
            int u = n;
            vector<pair<int,int>> aa;
            while(k < K){
                if (v == 0) break;
                if (u != n){
                    aa.pb({v, u});
                }
                k++;
                u = v;
                v = a[v];
            }
            reverse(aa.begin(), aa.end());
            for (auto x: aa){
                for (int j = 1; j < K; j++){
                    p[x.F][j] /= (1 + p[x.S][j - 1]) / 2;
                }
            }
            u = n;
            v = a[n];
            k = 0;
            p[v][0] /= 2;
            while(k < K){
                if (v == 0) break;
                for (int j = 1; j < K; j++){
                    p[v][j] *= (1 + p[u][j - 1]) / 2;
                }
                k++;
                u = v;
                v = a[v];
            }
        } else{
            double ans = 0;
            for (int i = 1; i < K; i++){
                ans += i * (p[v][i] - p[v][i - 1]);
            }
            cout << ans << '\n';
        }
    }
}

#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 500000 + 10;
const int D = 80;

int n, m;
int father[N];
double f[N][D];
double delta[N];

void solve()
{
	n = 1;
	f[0][0] = 1;
	father[0] = -1;
	cin >> m;
	for( ; m --; ) {
		int t, p;
		scanf("%d%d", &t, &p);
		--p;
		if (t == 1) {
			int u = n ++;
			father[u] = p;
			f[u][0] = 1;
			int pre = u;
			for(int i = 1, v = father[u]; v >= 0 && i < D; ++ i, v = father[v]) {
				if (pre != u) {
					double tmp = 1 - f[v][i];
					tmp /= (0.5 + 0.5 * (1 - f[pre][i - 1]));
					delta[v] = 1 - tmp;
				} else {
					delta[v] = f[v][i];
				}
				pre = v;
			}
			pre = u;
			for(int i = 1, v = father[u]; v >= 0 && i < D; ++ i, v = father[v]) {
				double tmp = 1 - delta[v];
				tmp *= (0.5 + 0.5 * (1 - f[pre][i - 1]));
				f[v][i] = 1 - tmp;
				pre = v;
			}
			/*
			cout << "ADD " << endl;
			for(int i = 0; i < n; ++ i) {
				cout << i << ": ";
				for(int j = 0; j < 3; ++ j) {
					cout << f[i][j] << ' ';
				}
				cout << endl;
			}
			*/
		} else {
			double ret = 0;
			for(int i = 1; i < D; ++ i) {
				ret += f[p][i];
			}
			printf("%.16f\n", ret);
		}
	}
}

int main()
{
	solve();
	return 0;
}

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <cstdio>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 500500;
const int K = 60;

int dad[MAX];
double f[MAX][K];

int main(void) {
  int n = 1;
  f[0][0] = 0;
  FOR(i, 1, K) f[0][i] = 1;
  dad[0] = -1;

  int q;
  scanf("%d", &q);
  while (q--) {
    int type, x;
    scanf("%d %d", &type, &x); --x;

    if (type == 1) {
      int nx = n++;
      dad[nx] = x;
      f[nx][0] = 0;
      FOR(i, 1, K) f[nx][i] = 1;

      int y = nx;
      double oldf = 1.0;
      FOR(h, 1, K) {
        if (x == -1) break;
        double tmp = f[x][h];
        f[x][h] *= (1 + f[y][h-1]) / (1 + oldf);
        oldf = tmp;
        y = x;
        x = dad[x];

      }
    } else {
      double ans = 0;
      REP(i, K) ans += f[x][i];
      ans = K-1 - ans;
      printf("%.12lf\n", ans);
    }
  }
  return 0;
}

//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const int U=70;

int q;
double d[500005][U];
int n=1;

int par[500005];

int main()
{
	int i, j, k, l;
	for(i=0;i<U;i++) d[0][i]=1;
	cin>>q;
	for(k=0;k<q;k++)
	{
		int x, y;
		scanf("%d%d", &x, &y), x--, y--;
		if(x == 0)
		{
			par[n]=y;
			for(i=0;i<U;i++) d[n][i]=1;
			int now=n;
			double tnow=0;
			for(i=0;i<U;i++)
			{
				int parent=par[now]; // parent 갱신
				if(now == 0) break;
				if(i == 0)
				{
					tnow=d[parent][0];
					d[parent][0]*=1./2;
				}
				else
				{
					double unow=d[parent][i];
					d[parent][i]/=(1./2+1./2*tnow);
					d[parent][i]*=(1./2+1./2*d[now][i-1]);
					tnow=unow;
				}
				now=par[now];
			}
			n++;
		}
		else
		{
			double ans=0;
			for(i=0;i<U;i++)
			{
				ans+=i*(d[y][i]-(i?d[y][i-1]:0));
			}
			printf("%.20lf\n", ans);
		}
	}
	return 0;
}
//*/

#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int Maxn=500010;
const int inf=2147483647;
const double eps=1e-7;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int tot=1,son[Maxn],fa[Maxn];
double f[Maxn][42];
int main()
{
	int q=read();
	for(int i=0;i<=40;i++)f[1][i]=1.0;
	while(q--)
	{
		int op=read(),v=read();
		if(op==1)
		{
			fa[++tot]=v;son[v]++;
			for(int i=0;i<=40;i++)f[tot][i]=1.0;
			double last=f[v][0];f[v][0]*=0.5;int d=0;
			while(v!=1)
			{
				int t=v;
				v=fa[v];
				if(d==40)break;
				double tmp=f[v][d+1];
				f[v][d+1]/=(0.5+0.5*last);
				f[v][d+1]*=(0.5+0.5*f[t][d]);
				d++;last=tmp;
			}
		}
		else
		{
			double ans=0.0;
			for(int i=1;i<=40;i++)ans+=(double)i*(f[v][i]-f[v][i-1]);
			printf("%.8lf\n",ans);
		}
	}
}

#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 500005, lim = 40;
int q, n = 1, p[MX];
ld dp[MX][lim];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(8);

	forn (i, MX) forn (j, lim) dp[i][j] = 1;

	cin >> q;
	while (q--) {
		int op, v;
		cin >> op >> v;

		if (op == 1) {
			p[++n] = v;

			ld aux = dp[v][0];
			dp[v][0] *= 0.5;

			int i = 1;
			while (v && i < lim) {
				ld t = dp[p[v]][i];
				dp[p[v]][i] *= (1 + dp[v][i - 1]) / (1 + aux);
				aux = t;
				v = p[v];
				i++;
			}
		} else {
			ld res = lim;

			forn (j, lim)
				res -= dp[v][j];

			cout << res << endl;
		}
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return a > val ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 500010;
const int magic = 75;
int p[maxn];
ld f[maxn][magic];

void solve() {
	FOR(i, 0, maxn) FOR(j, 0, magic) f[i][j] = 1;
	int n = 1, q;
	p[0] = -1;
	cin>>q;
	FOR(i, 0, q) {
		int op, v; cin>>op>>v; v--;
		if (op == 1) {
			int cur = n;
			p[n++] = v;
			ld t = f[v][0];
			f[v][0] *= 0.5;
			cur = p[cur];
			for (int i = 1; i < magic && cur != -1 && p[cur] != -1; i++, cur = p[cur]) {
				ld tmp = (1 + f[cur][i - 1]) / (1 + t);
				t = f[p[cur]][i];
				f[p[cur]][i] *= tmp;
			}
		}
		else {
			ld res = 0;
			FOR(i, 1, magic) {
				res += i * (f[v][i] - f[v][i - 1]);
			}
			cout<<prec(9)<<res<<"\n";
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(CC) {cerr<<#CC<<"=";for(auto&cc:CC)cerr<<cc<<",";cerr<<endl;}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(CC) {}
#define cerr if(0)cout
#endif

const int MaxQ = 500005;
const int K = 70;

LD probabNot[MaxQ][K];
int parent[MaxQ];
int nverts = 1;

void update(int v) {
  probabNot[v][0] = 0;
  LD veryold, old;

  for (int k = 1; k < K; k++) {
    int p = parent[v];
    if (!p) { return; }

    old = probabNot[p][k];

    if (k == 1) {
      probabNot[p][k] *= 0.5 * (1 + probabNot[p][k - 1]);
    } else {
      probabNot[p][k] /= (1 + veryold);
      probabNot[p][k] *= (1 + probabNot[v][k - 1]);
    }
    debug(p, k, probabNot[p][k]);

    veryold = old;
    v = p;
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int Q;
  cin >> Q;
  for (int i = 0; i <= Q; i++) {
    fill(probabNot[i], probabNot[i] + K, (LD)(1));
  }
  parent[1] = 0;
  probabNot[1][0] = 0;

  for (int i = 0; i < Q; i++) {
    int type, v;
    cin >> type >> v;
    debug(type, v);

    if (type == 1) {
      nverts++;
      parent[nverts] = v;
      update(nverts);
    } else {
      LD result = 0;
      for (int j = 1; j < K; j++) {
        result += (1 - probabNot[v][j]);
      }
      cout << result << "\n";
    }
  }
}

#include<bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long int ll;
typedef double lf;

const int inf = 987654321;
const ll INF = 123456789987654321;

#define pb push_back
#define rs resize
#define cl clear

int Q;
vector<vector<lf> > dp;
vector<int> par;
int main() {
    scanf("%d", &Q);
    dp = vector<vector<lf> >(Q, vector<lf>(60, 0.));
    for(int i = 0; i < 60; i++) dp[0][i] = 1.;
    int cnt = 1;
    par = vector<int>(Q, -1);
    for(int i = 0; i < Q; i++) {
        int t, v; scanf("%d %d", &t, &v); v--;
        if(t == 1) {
            par[cnt++] = v;
            int now = v;
            lf p2 = 1, p3 = 0;
            for(int i = 0; i < 60; i++) dp[cnt - 1][i] = 1.;
            for(int i = 0; i < 60; i++) {
                lf p1 = 2*dp[now][i]/(1+p2);
                p2 = dp[now][i];
                dp[now][i] = 0.5*p1+0.5*p1*p3;
                p3 = dp[now][i];

//                cout << now << ' ' << i << ' ' << p2 << ' ' << p3 << endl;

                if(now == 0) break;
                now = par[now];
            }
        }
        else {
            lf tot = 0;
            for(int i = 0; i < 60; i++) {
                tot += (lf)i*dp[v][i];
                if(i != 0) tot -= (lf)i*dp[v][i - 1];
            }
            printf("%.20lf\n", tot);
        }
    }
}

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<19, C = 60;
int p[maxn], sz = 1;
ld dp[maxn][C], ans[maxn];
void create(int v) {
	dp[sz][0] = 1;
	p[++sz] = v;
	ld prev = 0;
	for(int lst = sz-1, h = 1; v && h < C; lst = v, h++, v = p[v]) {
		ld old = (dp[v][h] - (prev/2))/(1.-(prev/2));
		prev = dp[v][h];
		dp[v][h] = old + (1.-old)*(dp[lst][h-1]/2);
		ans[v] -= prev;
		ans[v] += dp[v][h];
	}
}
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	memset(dp, 0, sizeof dp);
	memset(ans, 0, sizeof ans);
	memset(p, 0, sizeof p);
	int q;
	cin >> q;
	dp[1][0] = 0;
	cout << fixed << setprecision(15);
	for(int t, v; q--;) {
		cin >> t >> v;
		if(t == 1) {
			create(v);
			//for(int i = 1; i <= sz; i++)
			//	for(int h = 0; h < 5; h++) cout << dp[i][0];
		} else cout << ans[v] << '\n';
	}
}

#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
const int Lim=50;
int n,tot_Node;
int prt[maxn];
double f[maxn][63];
inline int Read(){
	register int ch,a;
	while(ch=getchar(),ch<'0'&&ch>'9');a=(ch^48);
	while(ch=getchar(),ch>='0'&&ch<='9')a=a*10+(ch^48);
	return a;
}
inline void Update(int u){
	for(int d=1;d<=Lim;d++)f[u][d]=1;
	double Last=1;
	for(int d=1;prt[u]&&d<=Lim;d++,u=prt[u]){
		double tmp=f[prt[u]][d];
		f[prt[u]][d]/=(Last+1)/2;
		f[prt[u]][d]*=(f[u][d-1]+1)/2;
		Last=tmp;
	}
}
inline double Query(int u){
	double ret=-1;
	for(int d=1;d<=Lim;d++)ret+=(f[u][d]-f[u][d-1])*d;
	return ret;
}
int main(){
	n=Read();
	tot_Node=1;
	for(int i=1;i<=Lim;i++)f[1][i]=1;
	int tp,u;
	while(n--){
		tp=Read(),u=Read();
		if(tp==1)prt[++tot_Node]=u,Update(tot_Node);
		else printf("%.8f\n",Query(u));
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 500005,M = 60;
int q,fa[N],n = 1;
double dp[N][M + 5];
int main ()
{
    ios::sync_with_stdio(false);
    cin >> q;
    int opt,pos;
    for (int i = 0;i <= M;i++) dp[1][i] = 1;
    for (int _ = 1;_ <= q;_++)
    {
        cin >> opt >> pos;
        if (opt == 1)
        {
            fa[++n] = pos;
            for (int i = 0;i <= M;i++) dp[n][i] = 1;
            double pre = 1;int pp = n;
            for (int i = 0,cur = pos;cur && i <= M;i++,cur = fa[cur])
            {
                double tmp = dp[cur][i];
                dp[cur][i] /= 0.5 * (pre + 1);
                if (i) dp[cur][i] *= 0.5 * (1 + dp[pp][i - 1]);
                else dp[cur][i] *= 0.5;
                pp = cur;pre = tmp;
            }
        }
        else
        {
            double ans = 0;
            for (int i = 1;i <= M;i++)
                ans += (dp[pos][i] - dp[pos][i - 1]) * i;
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}
//一道需要忽略误差的题......

#include <bits/stdc++.h>

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define in(x) int (x); input((x));
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)

typedef int itn;

//#define next next12345
//#define prev prev12345
#define left lefdsf232
#define right rig43783
#define x1 x12345
#define y1 y12345

using namespace std;

template<typename T>
T gcd(T x, T y) {
    while (y > 0) {
        x %= y;
        swap(x, y);
    }
    return x;
}

template<class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<class _T>
inline _T sqr(const _T &x) {
    return x * x;
}

template<class _T>
inline string tostr(const _T &a) {
    ostringstream os("");
    os << a;
    return os.str();
}

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const ld PI = 3.1415926535897932384626433832795L;

template<typename T>
inline void input(T &a) {
    static int ed;
    a = 0;
    while (!isdigit(ed = getchar()) && ed != '-') { }
    char neg = 0;
    if (ed == '-') {
        neg = 1;
        ed = getchar();
    }
    while (isdigit(ed)) {
        a = 10 * a + ed - '0';
        ed = getchar();
    }
    if (neg) a = -a;
}

template<typename T = int>
inline T nxt() {
    T res;
    input(res);
    return res;
}

void myassert(bool v) {
    assert(v);
    //cout << "FAIL\n";
    //exit(0);
}

mt19937 generator;

bool check(int v) {
    if (v < 2) return false;
    for (int i = 2; i * i <= v; ++i) {
        if (v % i == 0) {
            return false;
        }
    }
    return true;
}

long long pw(long long a, long long n, long long m) {
    ll res = 1;
    while (n) {
        if (n & 1ll) {
            res = res * a % m;
        }
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

long long inv(long long a, long long p) {
    long long res = 1;
    while (a > 1) {
        res = res * (p - p / a) % p;
        a = p % a;
    }
    return res;
}
vector <int> p;

const int M = 60;

#define ld double

ld dp[1 << 19][M];
ld old[M];
ld old2[M];

void solve(int test) {
    p.resize(1, -1);
    int q = nxt();
    vector <pair <int, int> > r;

    while (q--) {
        int t = nxt();
        int v = nxt() - 1;
        r.pb(mp(t, v));
        if (t == 1) {
            p.pb(v);
        }
    }
    forn(i, M) dp[0][i] = 1;

    int sz = 1;
    for (auto v : r) {
        if (v.x == 1) {
            int cur = sz++;
            forn(i, M) dp[cur][i] = 1;
            int pr = cur;
            cur = p[cur];
            int h = 0;
            while (cur != -1 && h < M) {
                memcpy(old2, dp[cur], sizeof(old2));
                for (int j = h; j < M; ++j) {
                    if (pr != sz - 1) dp[cur][j] /= (0.5 + 0.5 * (j ? old[j - 1] : 0));
                    dp[cur][j] *= (0.5 + 0.5 * (j ? dp[pr][j - 1] : 0));
                }
                memcpy(old, old2, sizeof(old));
                pr = cur;
                cur = p[cur];
                ++h;
            }
        } else {
            ld ans = 0;
            for (int i = 0; i < M; ++i) {
                ans += 1 - dp[v.y][i];
            }
            printf("%.10f\n", (double)ans);
        }
    }
}

int main(int argc, char ** argv) {

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    #define fname "sequence"
    //freopen(fname".in", "r", stdin);
    //freopen(fname".out", "w", stdout);
#endif
    //ios_base::sync_with_stdio(false);
//    pre();
    int t = 1;

#ifdef LOCAL
#else
#endif
    int c = 0;

    while (t--) {
        solve(++c);
    }

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAGIC = 80;
typedef long double ld;

int q;
int on = 2;
int p[500013];
ld prod[500013][MAGIC];

int main() {
	for (int i=0;i<500013;i++) fill(prod[i],prod[i]+MAGIC,1);
	scanf("%d",&q);
	while (q--) {
		int type, v;
		scanf("%d%d",&type,&v);
		if (type==1) {
			p[on] = v;
			on+=1;
			vector<int> has;
			for (int r=0;r<MAGIC-1;r++) {
				has.push_back(v);
				v = p[v];
			}
			for (int i=MAGIC-2;i>=0;i--) {
				int x = has[i];
				prod[p[x]][i+1]/=(0.5+prod[x][i]/2);
			}
			prod[has[0]][0]/=2;
			for (int i=0;i<MAGIC-1;i++) {
				int x = has[i];
				prod[p[x]][i+1]*=(0.5+prod[x][i]/2);
			}
        } else {
			ld ans = 0;
			for (int i=1;i<MAGIC;i++) {
				ans+=i*(prod[v][i]-prod[v][i-1]);
			}
			printf("%1.9f\n",(double) ans);
		}
	}

	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 500005
#define LIM 80

using namespace std;
typedef long double ld;

int par[SIZE],dep[SIZE];
ld dp[SIZE][LIM];

int main()
{
	int q;
	scanf("%d",&q);
	par[0]=-1;
	dep[0]=0;
	dp[0][0]=1.0;
	int sz=1;
	for(int i=0;i<q;i++)
	{
		int tp,v;
		scanf("%d %d",&tp,&v);v--;
		if(tp==1)
		{
			par[sz]=v;
			dep[sz]=0;
			dp[sz][0]=1.0;//���̐[���ɂ�����m��
			int now=sz;
			ld bef=1.0;
			for(int i=1;i<LIM;i++)
			{
				ld nxt=1.0-dp[v][i]/2.0;
				ld back=1.0-dp[v][i];//dp[v][i]=1.0-mul{1.0-dp[ch][i-1]/2.0}
				back/=bef;//bef>=1/2
				back*=1.0-dp[now][i-1]/2.0;
				dp[v][i]=1.0-back;
				bef=nxt;
				now=v;
				v=par[v];
				if(v==-1) break;
			}
			sz++;
		}
		else
		{
			ld ans=0.0;
			for(int i=1;i<LIM;i++) ans+=dp[v][i];
			printf("%.10f\n",(double) ans);
		}/*
		for(int i=0;i<sz;i++)
		{
			for(int j=0;j<=5;j++) printf("%f ",(double) dp[i][j]);puts("");
		}*/
	}
	return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cctype>
#include<set>
#include<vector>
#include<queue>
#include<map>
#define fi(s) freopen(s,"r",stdin);
#define fo(s) freopen(s,"w",stdout);
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
    for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 500005;
const int H = 60;

double f[N][H+2];
int fa[N], n = 1;

void add(int x) {
	fa[++n] = x;
	for (int i=0; i<=H; ++i) f[n][i] = 1;
	double t1 = f[x][0], t2;
	f[x][0] *= 0.5;
	for (int i=1; i<=H; ++i, x=fa[x]) {
		int p = fa[x]; if (!p) break;
		t2 = f[p][i];
		f[p][i] = f[p][i] / (0.5 + 0.5 * t1);
		f[p][i] = f[p][i] * (0.5 + 0.5 * f[x][i - 1]);
		t1 = t2;
	}
}
void query(int x) {
	double ans = 0;
	for (int i=1; i<=H; ++i)
		ans += i * (f[x][i] - f[x][i - 1]);
	printf("%.10lf\n",ans);
}
int main() {
	int Q = read();
	for (int i=0; i<=H; ++i) f[1][i] = 1;
	while (Q --) {
		int opt = read(), a = read();
		if (opt == 1) add(a);
		else query(a);
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mx=36;
struct pvt{
  vector<double> v;
  pvt(){
    v.resize(mx,0);
  }
};
void mkad(pvt& tg, const pvt& a){
  forn(i,mx){
    if(a.v[i]==0)
      break;
    tg.v[i]=tg.v[i]+a.v[i]-tg.v[i]*a.v[i];
  }
}
void mkrm(pvt& tg, const pvt& a){
  forn(i,mx){
    if(a.v[i]==0)
      break;
    tg.v[i]=(tg.v[i]-a.v[i])/(1-a.v[i]);
  }
}
void mksft(pvt& tg){
  for(in i=mx-1;i>0;--i)
    tg.v[i]=tg.v[i-1];
  tg.v[0]=1;
  forn(i,mx){
    tg.v[i]*=0.5;
    if(tg.v[i]<1e-14)
      tg.v[i]=0;
  }
}
vector<pvt> pvts,pvtr;
VI pr;
void mknu(in p){
  in s=sz(pr);
  pr.PB(p);
  pvts.PB(pvt());
  pvtr.PB(pvt());
  mksft(pvtr.back());
  mkad(pvts[p],pvtr.back());
  s=p;
  p=pr[s];
  in ct=1;
  while(ct<mx && p!=s){
    ++ct;
    mkrm(pvts[p],pvtr[s]);
    pvtr[s]=pvts[s];
    mksft(pvtr[s]);
    mkad(pvts[p],pvtr[s]);
    s=p;
    p=pr[s];
  }
  pvtr[s]=pvts[s];
  mksft(pvtr[s]);
}
double ans(in p){
  double r=0;
  forn(i,mx)
    r+=pvts[p].v[i];
  return r;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  pr.PB(0);
  pvtr.PB(pvt());
  mksft(pvtr[0]);
  pvts.PB(pvt());
  in q;
  scanf("%d",&q);
  in typ;
  in p;
  forn(zz,q){
    scanf("%d%d",&typ,&p);
    --p;
    if(typ==1){
      mknu(p);
    }
    else{
      printf("%.10lf\n",ans(p));
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAGIC = 39;
typedef double ld;

int q;
int on = 2;
int p[500013];
ld prod[500013][MAGIC];

int main() {
	for (int i=0;i<500013;i++) fill(prod[i],prod[i]+MAGIC,1);
	scanf("%d",&q);
	while (q--) {
		int type, v;
		scanf("%d%d",&type,&v);
		if (type==1) {
			p[on] = v;
			on+=1;
			vector<int> has;
			for (int r=0;r<MAGIC;r++) {
				if (!v) break;
				has.push_back(v);
				v = p[v];
			}
			for (int x: vector<int>(has.rbegin(),has.rend())) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]/=(0.5+prod[x][i-1]/2);
				}
			}
			prod[has[0]][0]/=2;
			for (int x: has) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]*=(0.5+prod[x][i-1]/2);
				}
			}
        } else {
			ld ans = 0;
			for (int i=1;i<MAGIC;i++) {
				ans+=i*(prod[v][i]-prod[v][i-1]);
			}
			printf("%1.9f\n",(double) ans);
		}
	}

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int LIM = 40;

vector<array<double, LIM>> P;
int Parent[500005];

void Remove(int node, int from, int i) {
	if(node == 0 || i >= LIM) return;

	Remove(Parent[node], node, i + 1);
	P[node][i] /= 0.5 * (P[from][i - 1] + 1.0);
}

void Add(int node, int from, int i) {
	if(node == 0 || i >= LIM) return;

	P[node][i] *= 0.5 * (P[from][i - 1] + 1.0);
	Add(Parent[node], node, i + 1);
}

int main() {
	int q, nodes = 1;
	P.push_back(array<double, LIM>());
	P.push_back(array<double, LIM>());
	fill(P.back().begin(), P.back().end(), 1.0);

	cin >> q;
	cout << fixed << setprecision(10);

	while(q--) {
		int t, v;
		cin >> t >> v;
		if(t == 1) {
			++nodes;

			P.push_back(array<double, LIM>());
			fill(P.back().begin(), P.back().end(), 1.0);

			Parent[nodes] = v;

			Remove(v, nodes, 1);
			Remove(Parent[v], v, 1);

			P[v][0] *= 0.5;

			Add(v, nodes, 1);
			Add(Parent[v], v, 1);
		} else {
			double ans = 0;
			for(int i = 1; i < LIM; ++i)
				ans += i * (P[v][i] - P[v][i-1]);
			cout << ans << '\n';
		}
	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef double dou;
const int N=5E5+5;
const int M=70;
int n=1,k,x,m,fa[N];
dou ans,now,last,f[N][M];

int main()
{
	cin>>m;
	for (int i=0;i<M;i++) f[n][i]=1;
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&k,&x);
		if (k==1)
		{
			fa[++n]=x;
			for (int i=0;i<M;i++) f[n][i]=1;
			now=1; last=2;
			for (int j=0;j<M&&x;j++,x=fa[x])
			{
				dou tmp=f[x][j];
				f[x][j]*=now/last;
				last=(1+tmp)*0.5;
				now=(1+f[x][j])*0.5;
			}
		} else
		{
			ans=0;
			for (int j=1;j<M;j++) ans+=(f[x][j]-f[x][j-1])*j;
			printf("%.7f\n",ans);
		}
	}
}

#include <bits/stdc++.h>

using namespace std;

const int N=501110,D=60;

int par[N];
double prob[N][D];
int n,Q;

void add(int v){
    par[++n]=v;
    for(int i=0;i<D;i++)
        prob[n][i]=1;
    prob[v][0]*=0.5;
    double old,oldVal=2*prob[v][0] ,newVal=prob[v][0];
    for(int i=1;i<D;i++){
        if(v==1) break;
        v=par[v];
        old=prob[v][i];
        prob[v][i]/=(0.5+0.5*oldVal);
        prob[v][i]*=(0.5+0.5*newVal);
        newVal=prob[v][i];
        oldVal=old;
    }
}

void printAns(int v){
    double ans=0;
    for(int i=1;i<D;i++)
        ans+=(prob[v][i]-prob[v][i-1])*i;
    printf("%.10f\n",ans);
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("674E.inp","r",stdin);
        freopen("674E.out","w",stdout);
    #endif // ONLINE_JUDGE
    scanf("%d",&Q);
    n=1;
    for(int i=0;i<D;i++) prob[1][i]=1;
    while(Q--){
        int type,v;
        scanf("%d%d",&type,&v);
        if(type==1)
            add(v);
        else
            printAns(v);
    }
}

#include <cstdio>
#include <cctype>
#include <algorithm>
#define gc() getchar()
#define MAX_H 60
const int N=5e5+5;

int n,fa[N];
double f[N][MAX_H];

inline int read()
{
    int now=0;register char c=gc();
    for(;!isdigit(c);c=gc());
    for(;isdigit(c);now=now*10+c-'0',c=gc());
    return now;
}

int main()
{
    n=1;
    for(int i=0; i<MAX_H; ++i) f[1][i]=1;
    for(int Q=read(),x; Q--; )
    {
        if(read()==1)
        {
            fa[++n]=x=read();
            for(int i=0; i<MAX_H; ++i) f[n][i]=1;
            double tmp1=f[x][0],tmp2;
            f[x][0]*=0.5;//深度还是不超过1啊
            for(int Fa=fa[x],i=1; Fa&&i<MAX_H; Fa=fa[x=Fa],++i)
            {
                tmp2=f[Fa][i];
                f[Fa][i] /= 0.5 + 0.5*tmp1;
                f[Fa][i] *= 0.5 + 0.5*f[x][i-1];
                tmp1=tmp2;
            }
        }
        else
        {
            x=read(); double ans=0;
            for(int i=1; i<MAX_H; ++i) ans+=(f[x][i]-f[x][i-1])*i;
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;

double dp[600000][50];
double mul[600000][50];
int par[600000];

int main(){
	int q;cin>>q;
	rep(i,q+10)rep(j,50)dp[i][j]=mul[i][j]=1;
	dp[0][0]=1;
	par[0]=-1;
	int cnt=0;
	rep(i,q){
		int ty;scanf("%d",&ty);
		if(ty==1){
			int p;scanf("%d",&p);p--;
			cnt++;
			par[cnt]=p;
			dp[par[cnt]][0]/=2;
			for(int v=par[cnt],j=0;par[v]!=-1&&j+1<50;v=par[v],j++){
				dp[par[v]][j+1]/=mul[v][j];
				mul[v][j]=(dp[v][j]+1)/2;
				dp[par[v]][j+1]*=mul[v][j];
			}
		}
		else{
			int v;scanf("%d",&v);v--;
			double ans=0;
			for(int i=0;i<50;i++){
				ans+=1-dp[v][i];
			}
			printf("%.12lf\n",ans);
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
#define M 500500
const int U = 40;
double f[U + 5][M];
int n, query;
int fa[M];
double inv2[100], t[100];
int sz[M];

double calc(int x) {
    double rlt = 0;
    for (int i = 1; i <= U; i++) {
        rlt += i * (f[i][x] - f[i-1][x]);
        //printf("i = %d, %.3lf, %.3lf\n", i, f[i][x] - f[i-1][x], i * (f[i][x] - f[i-1][x]));
    }
    return rlt;
}

void create(int x) {
    for (int i = 0; i <= U; i++) {
        f[i][x] = 1;
        //printf("f[%d][%d] = %.3lf\n", i, x, f[i][x]);
    }
}

void init() {
    inv2[0] = 1.;
    for (int i = 1; i < 100; i++) inv2[i] = inv2[i-1] / 2.;
}

void update(int x, int p) {
    fa[x] = p;
    ++sz[p];
    x = p;
    double g;
    t[0] = 1;
    for (int i = 1; i <= U && x; i++, x = fa[x]) {
        for (int a = i; a >= 1; a--) {
            g = f[a][x] * t[a-1];
            t[a] = (1 + g) / (1 + f[a][x]);
            f[a][x] = g;
            //printf("f[%d][%d] = %.3lf\n", a, x, f[a][x]);
        }
        if (sz[x] >= U) {
            g = 0;
        } else {
            //printf("sz[%d] = %d\n", x, sz[x]);
            g = inv2[sz[x]];
        }
        t[0] = (1 + g) / (1 + f[0][x]);
        f[0][x] = g;
        //int a = 0;
        //printf("f[%d][%d] = %.3lf\n", a, x, f[a][x]);
    }
}

int main() {
    scanf("%d", &query);
    init();
    n = 1;
    create(1);
    for (int type, x; query--; ) {
        scanf("%d", &type);
        scanf("%d", &x);
        if (type == 1) {
            ++n;
            create(n);
            update(n, x);
        } else {
            printf("%.10lf\n", calc(x));
        }
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 500010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int Q,cnt;
double f[maxn][45];
int fa[maxn],son[maxn];
double quick_pow(double x,int p)
{
    double an=1,po=x;
    while(p)
    {
        if(p&1)  an*=po;
        po*=po;
        p>>=1;
    }
    return an;
}
int main()
{
    cnt=1;
    for(int i=0;i<=40;i++)  f[1][i]=1;
    Q=read();
    while(Q--)
    {
        int op=read(),x=read();
        if(op==1)
        {
            cnt++;
            fa[cnt]=x;
            son[x]++;
            double las=f[x][0];
            f[x][0]=quick_pow(0.5,son[x]);
            for(int i=0;i<=40;i++)  f[cnt][i]=1;
            for(int i=1;i<=40;i++)
            {
                int u=fa[x];
                if(!u)  break;
                double tmp=f[u][i];
                f[u][i]/=(0.5+0.5*las);
                f[u][i]*=(f[x][i-1]*0.5+0.5);
                las=tmp;
                x=u;
            }
        }
        else{
            double ans=0;
            for(int i=1;i<=40;i++)  ans+=(double)i*(f[x][i]-f[x][i-1]);
            printf("%.8lf\n",ans);
        }
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
typedef double llf;
#define X first
#define Y second

const int MAX = 1<<19, MAXDUB = 40;
const llf GRAN = 1 - (1e-9);

int vr=1;
int par[MAX];
P q[MAX];
llf umn[MAX][MAXDUB];

void Makni(int ja, int ch, int indd)
{
  umn[ja][indd] /= (0.5 * umn[ch][indd-1] + 0.5);
}

void Stavi(int ja, int ch, int indd)
{
  umn[ja][indd] *= (0.5 * umn[ch][indd-1] + 0.5);
}

void Dodaj(int node)
{
  int tmp = node;
  vector <int> V;

  for (int i=0; i<MAXDUB && node; i++, node=par[node])
    V.push_back(node);
  V.push_back(par[node]);

  for (int i=(int) V.size()-1; i>0; i--)
    Makni(V[i], V[i-1], i);

  umn[tmp][0] = 0;

  for (int i=0; i<(int) V.size()-1; i++)
    Stavi(V[i+1], V[i], i+1);
}

int main()
{
  int brq;
  int ind = 1;

  scanf("%d", &brq);

  for (int i=0; i<MAX; i++)
    for (int j=0; j<MAXDUB; j++)
      umn[i][j] = 1;

  umn[0][0] = 0;
  for (int i=0; i<brq; i++) {
    scanf("%d%d", &q[i].X, &q[i].Y); q[i].Y--;
    if (q[i].X == 1) {
      par[ind] = q[i].Y;
      Dodaj(ind++);
    }
    else {
      llf ret = 0;
      for (int j=1; j<MAXDUB; j++)
        ret += 1 - umn[q[i].Y][j];

      printf("%.10lf\n", (double) ret);
    }
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
// #define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()
typedef long double f80;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
    uniform_int_distribution<ll> uid(l, r);
    return uid(rng);
}

const int H = 60;
const int N = 5e5 + 5;

f80 dp[N][H];
int par[N];
int n = 0;

void add(int v) {
	n++;
	par[n] = v;
	fr(i, 0, H - 1) {
		dp[n][i] = 1;
	}
	vector<int> anc;
	v = n;
	for(int i = 0; i < H; i++) {
		if(!v) break;
		anc.pb(v);
		v = par[v];
	}
	for(int i = sz(anc) - 2; i > 0; i--) {
		int u = anc[i], p = anc[i + 1];
		dp[p][i + 1] /= ((1 + dp[u][i]) / 2.0);
		dp[p][i] /= ((1 + dp[u][i - 1]) / 2.0);
	}
	if(sz(anc) > 1)
		dp[anc[1]][0] /= 2;
	for(int i = 0; i < sz(anc) - 1; i++) {
		int u = anc[i], p = anc[i + 1];
		dp[p][i + 1] *= ((1 + dp[u][i]) / 2.0);
		if(i > 0)
		dp[p][i] *= ((1 + dp[u][i - 1]) / 2.0);
	}
}

f80 query(int u) {
	f80 ans = 0;
	fr(i, 1, H - 1) {
		ans += i * (dp[u][i] - dp[u][i - 1]);
	}
	return ans;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q;
    cin >> q;
    add(0);
    while(q--) {
    	int t, v;
    	cin >> t >> v;
    	if(t == 1) {
    		add(v);
    	}
    	else {
    		cout << setprecision(10) << fixed << query(v) << endl;
    	}
    }
	return 0;
}

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long INT;
typedef vector<int> VI;
typedef pair<int, int> pii;

template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}
template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}
int power(int a, int b, int m, int ans=1){for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m; return ans;}

#define NN 500500
#define M 50
typedef double DO;
DO dp[NN][M];
int fa[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif

	int q;
	int n=1;
	for(int i=0; i<M; i++) dp[n][i]=1;

	cin >> q;
	int tp, u;
	while(q--){
		gn(tp, u);
		if(tp==1){
			int v=++n;
			fa[v]=u;
			for(int i=0; i<M; i++) dp[v][i]=1;
			VI vec;
			for(int i=0; i<M && u; i++) vec.pb(u), u=fa[u];
			for(int i=vec.size(); i--; ){
				if(i) dp[vec[i]][i]/=(dp[vec[i-1]][i-1]+1)/2;
				else dp[vec[i]][i]*=0.5;
			}
			for(int i=1; i<vec.size(); i++){
				dp[vec[i]][i]*=(dp[vec[i-1]][i-1]+1)/2;
			}
		}
		else {
			DO ans=0;
			for(int i=1; i<M; i++) ans+=i*(dp[u][i]-dp[u][i-1]);
			printf("%.10lf\n", ans);
		}
	}

	return 0;
}

#include <cstdio>
using namespace std;
typedef long double ld;

const int MAXN = 500005;
const int MAXH = 50;
int N = 1, Q;
ld dp[MAXN][MAXH];
int par[MAXN];
ld E[MAXN];

int main()
{
    scanf("%d", &Q);
    dp[1][0] = 1;
    for (int q = 0, type, v; q < Q; q++)
    {
        scanf("%d %d", &type, &v);
        if (type == 1)
        {
            par[++N] = v;
            v = N;
            dp[v][0] = 1;
            ld oldval = 0;
            for (int i = 0; i < MAXH - 1 && v != 0; i++, v = par[v])
            {
                E[par[v]] -= dp[par[v]][i + 1];
                ld temp = dp[par[v]][i + 1];
                dp[par[v]][i + 1] = 1 - (1 - dp[par[v]][i + 1])/(1 - oldval/2)*(1-dp[v][i]/2);
                oldval = temp;
                E[par[v]] += dp[par[v]][i + 1];
            }
        }
        else
            printf("%.10f\n", (double)E[v]);
    }

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

#define sz(a) int(a.size())
#define all(x) (x).begin(), (x).end()

#define dbg(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {
    cerr << str << " : " << t << "\n";
}
template <class T, class... S> void dbs(string str, T t, S... s) {
    int idx = str.find(',');
    cerr << str.substr(0, idx) << " : " << t << ",";
    dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator <<(ostream& os, const pair<S, T>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template <class T> void debug(T a, T b) {
    cerr << "[";
    for (T i = a; i != b; ++i) {
        if (i != a) cerr << ", ";
        cerr << *i;
    }
    cerr << "]\n";
}

const int H = 50;
const int N = 500050;

double dp[N][H];
int parent[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout.precision(12);

    int n = 1;
    for (int i = 0; i < H; ++i) {
        dp[0][i] = 1.0;
    }
    parent[0] = -1;

    int q;
    cin >> q;
    while (q--) {
        int type, v;
        cin >> type >> v;
        --v;
        if (type == 1) {
            parent[n] = v;
            for (int i = 0; i < H; ++i) {
                dp[n][i] = 1.0;
            }
            dp[v][0] *= 0.5;
            double cur = dp[v][0];
            double prev = 2.0 * cur;
            for (int u = parent[v], h = 1; u >= 0 and h < H; ++h) {
                double tmp = dp[u][h];
                dp[u][h] /= (1.0 + prev) / 2;
                dp[u][h] *= (1.0 + cur) / 2;
                cur = dp[u][h];
                prev = tmp;
                u = parent[u];
            }
            ++n;
        } else {
            double ans = 0;
            for (int i = 1; i < H; ++i) {
                ans += (dp[v][i] - dp[v][i - 1]) * i;
            }
            cout << ans << "\n";
        }
    }

    return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <memory.h>

using namespace std;

int t[500005], v[500005];
vector<int> g[500005];

const int MAXP = 40;
const int N = MAXP;

struct SegmentTree {
  SegmentTree(int _n = 0) : n(_n) {
    init(_n);
  }

  void init(int _n) {
    n = _n;
    tree = vector<vector<double>>(n + 1, vector<double>(N, 1.0));

    // tree[n + 1] = vector<double>(N, 0);
    // tree[n + 1][0] = 1.0;
  }

  void update(int pos, double val, int where) {
    // for (int i = 1; i < v.size(); ++i)
    //   v[i] += v[i - 1];

    // for (int i = 0; i < tree[pos].size(); ++i) {
    //   tree[n][i] /= tree[pos][i];
    // }
    // for (int i = 0; i < v.size(); ++i) {
    //   tree[n][i] *= v[i];
    // }

    tree[n][where] = tree[n][where] / tree[pos][where] * val;

    // for (int i = 0; i < N; ++i) {
    //   tree[n + 1][i] = tree[n][i] - (i > 0 ? tree[n][i - 1] : 0);
    // }
    tree[pos][where] = val;
  }

  vector<double>& get() {
    return tree[n];
  }

  int n;
  vector<vector<double>> tree;
};

SegmentTree Q[500005];

int par[500005], POS[500005];

int main() {
  // Q[0].init(500000);
  int q;
  scanf("%d", &q);
  int cnt = 1;
  memset(par, -1, sizeof(par));
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &t[i], &v[i]); --v[i];
    if (t[i] == 1) {
      POS[cnt] = g[v[i]].size();
      g[v[i]].push_back(cnt);
      par[cnt] = v[i];
      ++cnt;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    Q[i].init(g[i].size());
  }

  cnt = 1;
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      vector<double> cur(N, 1.0);
      cur[0] = 0.5; cur[1] = 1.0;
      int x = cnt, it = 0, where = 0;
      while (par[x] != -1 && it < N) {
        ++it;
        // cout << x << "  " << par[x] << "  " << POS[x] << endl;
        Q[par[x]].update(POS[x], cur[where], where); ++where;
        x = par[x];
        // cur = Q[x].get();
        if (where < N)
          cur[where] = Q[x].get()[where - 1] * 0.5 + 0.5;
        // vector<double> tmp(1, 0.5);
        // for (int i = 0; i < cur.size() && i < N; ++i) {
        //   tmp.push_back(0.5 * cur[i] + 0.5);
        // }
        // cur = tmp;
      }
      ++cnt;
    } else {
      double ans = 0;
      vector<double> X = Q[v[i]].get();
      for (int j = 1; j < X.size(); ++j) {
        ans += j * (X[j] - X[j - 1]);
      }
      printf("%.10lf\n", ans);
    }
  }

  // {
  //   int N = 1000, C = 1;
  //   cout << N << endl;
  //   for (int i = 0; i < N; ++i) {
  //     int T = (rand() & 1) + 1;
  //     cout << T << " " << (rand() % C) + 1 << endl;
  //     if (T == 1) ++C;
  //   }
  // }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAGIC=40;
int N, M;
vector<int> adj[500001];
int par[500001];
double S[500001][MAGIC];

void update(int u, int l)
{
    if(u!=1 && l+1<MAGIC)
    {
        update(par[u], l+1);
        S[par[u]][l+1]/=1+S[u][l];
    }
    if(l==0)
    {
        S[u][l]*=0.5;
        while(par[u] && l+1<MAGIC)
        {
            S[par[u]][l+1]*=1+S[u][l];
            u=par[u];
            l++;
        }
    }
}

int main()
{
    scanf("%d", &N);
    for(int i=0; i<MAGIC; i++)
        S[1][i]=1.0;
    M=1;
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        if(a==1)
        {
            adj[b].push_back(++M);
            par[M]=b;
            for(int j=0; j<MAGIC; j++)
                S[M][j]=1.0;
            update(b, 0);
        }
        else
        {
            double ans=0.0;
            for(int j=1; j<MAGIC; j++)
                ans+=j*(S[b][j]-S[b][j-1]);
            printf("%.6f\n", ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n = 100;
    ll q;
    cin >> q;
    vector<vector<double>> a((size_t) n + 1, vector<double>((size_t) q + 1, 1));
    vector<ll> b((size_t) q + 1, -1);
    for (ll t = 0, z = 1; t < q; t++) {
        ll x, y;
        cin >> x >> y;
        y--;
        if (x == 1) {
            vector<ll> c;
            for (ll i = y, j = 1; i != -1 && j <= n; i = b[i], j++) {
                c.push_back(i);
            }
            for (ll i = (ll) c.size() - 1; i >= 1; i--) {
                a[i][c[i]] /= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            b[z] = y;
            a[0][y] *= 0.5;
            for (ll i = 1; i < (ll) c.size(); i++) {
                a[i][c[i]] *= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            z++;
        }
        if (x == 2) {
            double j = 0;
            for (ll i = 0; i <= n; i++) {
                j += (a[i][y] - (i == 0 ? 0 : a[i - 1][y])) * i;
            }
            cout << setprecision(100) << j << "\n";
            cout.flush();
        }
    }
    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

const int max_d = 50;
int n = 1;
int p[500050];
// dp[v][l] - prob that vertex v has depth < l
double dp[500050][max_d] = {0};

int main() {
	p[0] = -1;
	dp[1][0] = 0.0;
	for (int i = 1; i < max_d; i++)
		dp[1][i] = 1.0;

	int q;
	scanf("%d", &q);
	while (q--) {
		int op;
		scanf("%d", &op);
		if (op == 1) {
			// new vertex
			int v = ++n;
			scanf("%d", &p[v]);

			int i = 0;
			double to_div = 1.0;
			while (p[v] != -1 && i + 1 < max_d) {
				double tmp = dp[p[v]][i + 1];
				dp[p[v]][i + 1] /= to_div;
				to_div = 0.5 * (1.0 + tmp);
				v = p[v];
				i++;
			}

			dp[n][0] = 0.0;
			for (int j = 1; j < max_d; j++)
				dp[n][j] = 1.0;
			v = n; i = 0;
			while (p[v] != -1 && i + 1 < max_d) {
				dp[p[v]][i + 1] *= (0.5 + 0.5 * dp[v][i]);
				v = p[v];
				i++;
			}
		} else if (op == 2) {
			// evaluate
			int v;
			scanf("%d", &v);
			double ans = 0.0;
			for (int i = 1; i < max_d; i++)
				ans += (i - 1) * (dp[v][i] - dp[v][i - 1]);
			printf("%.12f\n", ans);
		}
	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <ios>
#include <iomanip>

using namespace std;

typedef long double ld;

const int maxn = 500100;
const int maxp = 40;

int n, q;
ld d[maxn][maxp];
int p[maxn];

void upd(int v, int k, ld x) {
    if (v == 0 || k >= maxp) return;

    ld a = d[v][k];
    d[v][k] *= x;
    upd(p[v], k + 1, (d[v][k] + 1) / (a + 1));
}

int main() {
    ios_base::sync_with_stdio(0);

    for (int i = 0; i < maxn; i++)
        for (int j = 0; j < maxp; j++)
            d[i][j] = 1;

    cin >> q;
    n = 1;
    for (int i = 0; i < q; i++) {
        int qtype, v;
        cin >> qtype >> v;
        if (qtype == 1) {
            p[++n] = v;
            upd(n, 0, 0);
        } else {
            ld ans = 0;
            for (int j = 1; j < maxp; j++)
                ans += (1 - d[v][j]);
            cout << fixed << setprecision(10) << ans << '\n';
        }
    }
}

#include <cstdio>
#include <numeric>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define fill(x,y) memset(x,y,sizeof(x))
#define prev PREV
#define next NEXT

typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> inline T sqr (T x) { re x * x; }

#define filename ""

const int N = 500100;
const int M = 50;
const double eps = 1e-10;

int n;
int m;

int h[N];
double sum[N];
double mult[N];
vi v[N];
int x[N];
int y[N];
int t[N];
int p[N];
double res[N][M];
double old[N][M];

int main () {
	scanf ("%d", &n);
	m = 1;
	for (int i = 0; i < n; i++) {
		scanf ("%d%d", &t[i], &x[i]); x[i]--;
		if (t[i] == 1) y[i] = m++;
	}
	res[0][0] = 1;
	for (int i = 0; i < n; i++)
		if (t[i] == 1) {
			p[y[i]] = x[i];
			int a = y[i];
			res[a][0] = 1;
			for (int it = 0; it + 1 < M && a != 0; it++) {
				int b = p[a];
				double sc = 0, sy = 0;
				for (int j = 0; j < M; j++) old[b][j] = res[b][j];
				if (it > 0) {
					res[b][0] = res[b][0] * 2;
					sc = res[b][0];
					sy = 0.5;
					double tmp = sc * sy;
					for (int j = 1; j < it + 2; j++) {
						sy += old[a][j - 1] * 0.5;
						res[b][j] = (res[b][j] + tmp - sc * sy) / sy;
						sc += res[b][j];
						tmp = sc * sy;
					}
				}
				sc = sy = 0;
				sc = res[b][0];
				sy = 0.5;
				res[b][0] = res[b][0] * 0.5;
				double tmp = sc * sy;
				for (int j = 1; j < it + 2; j++) {
					sc += res[b][j];
					sy += res[a][j - 1] / 2;
					double mul = sc * sy;
					res[b][j] = mul - tmp;
					tmp = mul;
				}
				a = b;
				if (abs (res[a][it] - old[a][it]) < eps) break;
			}
		} else {
			double ans = 0;
			for (int j = 1; j < M; j++)
				ans += res[x[i]][j] * j;
			printf ("%.10f\n", ans);
		}
	cerr << clock () << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int q;
int p[500010];
int vert = 1;
double prob[500010][51];
vector<int> children[500010];
int main()
{
    scanf("%d", &q);
    prob[0][0] = 1;
    p[0] = 0;
    while(q--)
    {
        int t, v;
        scanf("%d%d", &t, &v);
        v--;
        if(t == 1)
        {
            p[vert] = v;
            children[v].push_back(vert);
            prob[vert][0] = 1;
            int cur = vert;
            int d = 0;
            double prevprob = 0, curprob = 1;
            do //slow updates for now
            {
                cur = p[cur];
                d++;
                double nope = (1 - prob[cur][d]);
                nope /= (1 - prevprob / 2);
                nope *= (1 - curprob / 2);
                prevprob = prob[cur][d];
                prob[cur][d] = 1 - nope;
                curprob = prob[cur][d];
            }
            while(cur != 0 && d < 50);
            vert++;
        }
        else
        {
            double sum = 0;
            for(int i=49; i>=0; i--)
            {
                sum += (prob[v][i] - prob[v][i+1]) * i;
            }
            printf("%.10f\n", sum);
        }
    }
    return 0;
}

#include<complex>
#include<cstdio>
using namespace std;
const int N=5e5+7,H=61;
int Q,n=1;
int fat[N];
double f[N][H];
int qread()
{
	int x=0;
	char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int main()
{
	scanf("%d",&Q);
	for(int i=0;i<H;i++)f[1][i]=1;
	int p,x;
	while(Q--)
	{
		p=qread();x=qread();
		if(p==1)
		{
			fat[++n]=x;
			for(int i=0;i<H;i++)f[n][i]=1;
			double t1=f[x][0],t2;
			f[x][0]*=0.5;
			for(int i=1,fa=fat[x];i<H && fa;i++,fa=fat[x=fa])
			{
				t2=f[fa][i];
				f[fa][i]/=0.5+0.5*t1;
				f[fa][i]*=0.5+0.5*f[x][i-1];
				t1=t2;
			}
		}
		else
		{
			double ans=0;
			for(int i=1;i<H;i++)
				ans+=(f[x][i]-f[x][i-1])*i;
			printf("%.6lf\n",ans);
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int maxn=500005;

inline int read(){
	register int x=0,w=1,ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;
	return w*x;
}

int q,tot,fa[maxn];
double f[maxn][52];

int main(){
	q=read(),tot=1;
	for(register int i=1;i<=50;i++)f[1][i]=1;
	for(register int op,x;q--;){
		op=read(),x=read();
		if(op==1){
			vector<int> v;
			fa[++tot]=x,x=tot;
			for(register int i=1;i<=50;i++)f[x][i]=1;
			for(register int i=1;i<=51&&x;i++)v.push_back(x),x=fa[x];
			for(register int i=v.size()-2;i>0;i--)
				f[v[i+1]][i+1]/=(f[v[i]][i]+1)/2.0;
			for(register int i=0;i+1<v.size();i++)
				f[v[i+1]][i+1]*=(f[v[i]][i]+1)/2.0;
		}
		else{
			register double ans=50;
			for(register int i=1;i<=50;i++)ans-=f[x][i];
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int M=70,N=501000;
double dp[N][M+5];
int n,x,ty,v,p[N];
int main() {
	scanf("%d",&n);
	int x=1;
	rep(i,1,M) dp[x][i]=1;
	rep(i,0,n) {
		scanf("%d%d",&ty,&v);
		if (ty==2) {
			double ret=0;
			rep(i,1,M) ret+=1-dp[v][i];
			printf("%.10f\n",ret);
		} else {
			x++; p[x]=v;
			rep(i,1,M) dp[x][i]=1;
			v=x;
			double prv=1;
			rep(j,1,M) {
				if (p[x]==0) break;
				double crv=0.5*(1+dp[p[x]][j]);
				dp[p[x]][j]/=prv;
				dp[p[x]][j]*=0.5*(1+dp[x][j-1]);
				prv=crv; x=p[x];
			}
			x=v;
		}
	}

}

#include <bits/stdc++.h>
using namespace std;

const int mxn=70,MX=501000;
double dp[MX][mxn+5];
int n,x,ty,v,p[MX];
int main() {
	scanf("%d",&n);
	int x=1;
	for ( int i = 1 ;i < mxn ; i ++ )
		dp[x][i]=1;
	for ( int i = 0 ;i < n ;i ++ ){
		scanf("%d%d",&ty,&v);
		if (ty==2) {
			double ret=0;
			for ( int j = 1 ;j < mxn ; j ++ )  ret+=1-dp[v][j];
			printf("%.10f\n",ret);
		}
		else {
			x++; p[x]=v;
			for ( int j = 1 ;j <mxn ;j ++)  dp[x][j]=1;
			v=x;
			double prv=1;
			for ( int j = 1 ; j< mxn ; j ++ ) {
				if (p[x]==0) break;
				double crv=0.5*(1+dp[p[x]][j]);
				dp[p[x]][j]/=prv;
				dp[p[x]][j]*=0.5*(1+dp[x][j-1]);
				prv=crv; x=p[x];
			}
			x=v;
		}
	}
	return 0;

}

#include <bits/stdc++.h>

#define FOR(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define x first
#define y second

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
//#define double long double

const double eps = 1e-10;

const int MS = 50;
class Magic{
public:
  double p[MS];
  Magic(){memset(p, 0, sizeof p);}
  double& operator[](int x){return p[x];}
  void display(){
    REP(i,MS) cout << p[i] << " "; cout << endl;
  }
};

Magic All[500005];
int par[500005];

int main(){
  ios_base::sync_with_stdio(false);

  All[1][0] = 1;

  int q;
  cin >> q;

  int CNT = 2;
  REP(j,q){
    int t, v;
    cin >> t >> v;
    if (t == 1){
      par[CNT] = v;
      double curr = 1;
      double prev = 0;
      int id = CNT;
      REP(i,MS-1){
	id = par[id];
	double tmp = All[id][i+1];
	All[id][i+1] = (All[id][i+1] - prev/2) / (1 - prev/2);
	All[id][i+1] = All[id][i+1] + curr/2 - All[id][i+1]*curr/2;
	prev = tmp;
	curr = All[id][i+1];
	if (id == 1) break;
      } ++CNT;
    } else {
      double e = 0;
      FOR(ii,1,MS) e += All[v][ii];
      cout << setprecision(25) << e << endl;
    }
  }

  return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <string>
#include <iomanip>
#include <queue>
#include <tuple>
#include <functional>
#include <numeric>
#include <sstream>
using namespace std;

typedef long double db;
const int maxh = 63;
const int maxn = 500000 + 100;

db dp[maxn][maxh], old[maxh];
int n, q, par[maxn];
int main() {
	scanf("%d", &q);
	n = 1;
	par[n] = 0;
	dp[n][0] = 0;
	for (int i = 1; i < maxh; i ++) {
		dp[n][i] = 1.0;
	}
	for (int i = 1; i <= q; i ++) {
		int t, v;
		scanf("%d%d", &t, &v);
		if (t == 1) {
			++ n;
			dp[n][0] = 0;
			old[0] = 1.0;
			for (int i = 1; i < maxh; i ++) {
				dp[n][i] = old[i] = 1.0;
			}
			int c = n;
			par[n] = v;
			int dep = 0;
			while (v != 0) {
				// update v, child = c
				++ dep;
				for (int i = dep; i <= dep; i ++) {
					old[i] = dp[v][i];
					dp[v][i] = dp[v][i] / (1 + old[i - 1]) * (1 + dp[c][i - 1]);
				}
				c = v;
				v = par[v];
				if (dep >= 60) break;
			}
		} else {
			db ans = 0;
			for (int i = 1; i < maxh; i ++) {
				ans += (dp[v][i] - dp[v][i - 1]) * i;
			}
			printf("%.9lf\n", (double)(ans - 1));
		}
	}
	return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#define LL long long
#define mp(x,y) make_pair(x,y)
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
inline void print(int x){write(x);printf(" ");}
double f[510000][45];
int fa[510000],son[510000];
double pow_mod(double a,int b)
{
	double ret=1;
	while(b)
	{
		if(b&1)ret=ret*a;
		a=a*a;b>>=1;
	}
	return ret;
}
int main()
{
	int o=1;
	for(int i=0;i<=40;i++)f[1][i]=1;
	int T=read();while(T--)
	{
		int op=read(),x=read();
		if(op==1)
		{
			o++;fa[o]=x;son[x]++;
			double lst=f[x][0];
			f[x][0]=pow_mod(0.5,son[x]);
			for(int i=0;i<=40;i++)f[o][i]=1;
			for(int i=1;i<=40;i++)
			{
				int u=fa[x];if(!u)break;
				double gg=f[u][i];
				f[u][i]/=(0.5+0.5*lst);
				f[u][i]*=(0.5+0.5*f[x][i-1]);
				lst=gg;x=u;
			}
		}
		else
		{
			double ans=0.0;
			for(int i=1;i<=40;i++)ans+=(f[x][i]-f[x][i-1])*(double)i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define re register
#define il inline
#define rep(i,a,b) for(re int i=(a);i<=(b);++i)
const int N =500005;
int Q,n;
int fa[N];
typedef double db;
db f[N][65],ans;
const db eps =1e-8;
void find(int u,int j,db pre){
	if(!fa[u]||j>60)return;
	db tmp=f[fa[u]][j+1];
	f[fa[u]][j+1]*=(f[u][j]+1)/(pre+1);
	find(fa[u],j+1,tmp);
}
int main(){
	scanf("%d",&Q);
	int op,ff;n=1;
	rep(i,0,60)
	f[1][i]=1;
	while(Q--){
		scanf("%d%d",&op,&ff);
		if(op==1){
			fa[++n]=ff;
			rep(i,0,60)
			f[n][i]=1;
			f[ff][0]*=0.5;
			find(ff,0,f[ff][0]*2);
		}
		else{
			ans=0;
			rep(i,1,60){
				ans+=(f[ff][i]-f[ff][i-1])*i;
			}
			printf("%.12lf\n",ans);
		}
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 500010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int Q,cnt;
double f[maxn][45];
int fa[maxn],son[maxn];
double quick_pow(double x,int p)
{
    double an=1,po=x;
    while(p)
    {
        if(p&1)  an*=po;
        po*=po;
        p>>=1;
    }
    return an;
}
int main()
{
    int bl=35;
    cnt=1;
    for(int i=0;i<=bl;i++)  f[1][i]=1;
    Q=read();
    while(Q--)
    {
        int op=read(),x=read();
        if(op==1)
        {
            cnt++;
            fa[cnt]=x;
            son[x]++;
            double las=f[x][0];
            f[x][0]=quick_pow(0.5,son[x]);
            for(int i=0;i<=bl;i++)  f[cnt][i]=1;
            for(int i=1;i<=bl;i++)
            {
                int u=fa[x];
                if(!u)  break;
                double tmp=f[u][i];
                f[u][i]/=(0.5+0.5*las);
                f[u][i]*=(f[x][i-1]*0.5+0.5);
                las=tmp;
                x=u;
            }
        }
        else{
            double ans=0;
            for(int i=1;i<=bl;i++)  ans+=(double)i*(f[x][i]-f[x][i-1]);
            printf("%.8lf\n",ans);
        }
    }
    return 0;
}

#include <stdio.h>
#include <vector>

using namespace std;

const size_t MAX_N = 500000;
const size_t MAX_DEPTH = 50;

double prob[MAX_N][MAX_DEPTH];

int main() {
  int q;
  scanf("%d", &q);

  vector<int> pre(1, -1);
  for (size_t j = 0; j < MAX_DEPTH; ++j)
    prob[0][j] = 1.0;

  int n = 1;
  for (; q; --q) {
    int type, v;
    scanf("%d%d", &type, &v);
    --v;

    if (type == 1) {
      pre.push_back(v);
      for (size_t j = 0; j < MAX_DEPTH; ++j)
        prob[n][j] = 1.0;

      int cur = n;
      double old_mult = 1.0;
      for (size_t h = 0; ; ++h) {
        int p = pre[cur];
        if (p == -1 || h == MAX_DEPTH)
          break;

        const double new_old_mult = 0.5 * (1.0 + prob[p][h]);
        prob[p][h] *= 0.5 * (1.0 + (h > 0 ? prob[cur][h - 1] : 0.0)) / old_mult;
        old_mult = new_old_mult;

        cur = p;
      }

      ++n;
    } else {
      double result = 0.0;
      for (size_t j = 0; j < MAX_DEPTH; ++j)
        result += 1.0 - prob[v][j];
      printf("%.12lf\n", result);
    }
  }

  return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef long double ld;

const int Maxn = 500005;
const int Maxm = 65;

int q;
int n = 2;
int P[Maxn];
ld has[Maxn][Maxm];

void Change(int v, int lvl, ld cur, ld old)
{
	if (!v || lvl >= Maxm) return;
	ld nold = has[v][lvl];
	ld x = (has[v][lvl] - old) / (1.0l - old);
	has[v][lvl] = x + cur - x * cur;
	Change(P[v], lvl + 1, has[v][lvl] / 2, nold / 2);
}

int main()
{
	scanf("%d", &q);
	while (q--) {
		int typ, v; scanf("%d %d", &typ, &v);
		if (typ == 1) { P[n++] = v; Change(n - 1, 0, 1.0l, 0.0l); }
		else {
			ld res = 0;
			for (int i = 1; i < Maxm; i++)
				res += has[v][i];
			printf("%.15lf\n", double(res));
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int D=55,N=500005;
int q,tot=1,fa[N];
double f[N][D+2];
vector<int>v;
int main(){
	//freopen("earth.in","r",stdin);
	//freopen("earth.out","w",stdout);
	scanf("%d",&q);
	for(int i=1;i<=D;i++)f[1][i]=1;
	for(int op,x;q--;v.clear()){
        scanf("%d%d",&op,&x);
		if(op==1){
			fa[++tot]=x,x=tot;
			for(int i=1;i<=D;i++)f[x][i]=1;
			for(int i=1;i<=D+1&&x;i++)v.push_back(x),x=fa[x];
			for(int i=v.size()-2;i>0;i--)
				f[v[i+1]][i+1]/=(f[v[i]][i]+1)/2.0;
			for(int i=0;i+1<v.size();i++)
				f[v[i+1]][i+1]*=(f[v[i]][i]+1)/2.0;
		}
		if(op==2){
			double ans=D;
			for(int i=1;i<D;i++)ans-=f[x][i];
			printf("%.10lf\n",ans-1);
		}
	}
	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define PB push_back
#define LL long long
#define inf 0x3f3f3f3f
#define fill(a,b) memset(a,b,sizeof(b))
#define cpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> inline bool MIN(T &a,const T &b) {return a>b? a=b,1:0;}
template<typename T> inline bool MAX(T &a,const T &b) {return a<b? a=b,1:0;}
#define N 500010
using namespace std;
int n;
int fa[N];
double f[N][55];

int main()
{
//	freopen("E.in","r",stdin);
	scanf("%d",&n);
	for (int i=0;i<=50;++i) f[1][i]=1;
	int cnt=1;
	for (int cas=1;cas<=n;++cas) {
		int ope,u;
		scanf("%d%d",&ope,&u);
		if (ope==1) {
			fa[++cnt]=u;
			u=cnt;
			for (int i=0;i<=50;++i) f[u][i]=1;

			double last=0;
			for (int c=0;c<50;++c) {
				if (!fa[u]) break;

				double t=f[fa[u]][c];
				if (!c) f[fa[u]][c]/=2;
				else f[fa[u]][c]=f[fa[u]][c]/(last/2+0.5)*(f[u][c-1]/2+0.5);
				last=t;
				u=fa[u];
			}
		} else {
			double ans=0;
			for (int i=1;i<50;++i) {
				double p=f[u][i]-f[u][i-1];
				ans+=p*i;
			}
			printf("%.12lf\n",ans);
		}
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}

const int MX = 500005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int D = 90;

int n;
int p[MX];
double ans[MX];
double d[MX][D+1];

void up(int v) {
  double x = 1, pre = 1, tmp;
  rep(di,D) {
    int u = p[v];
    if (u == -1) break;
    x /= 2;
    tmp = d[u][di+1];
    d[u][di+1] /= (pre+1)/2;
    pre = tmp;
    x *= d[u][di+1];
    d[u][di+1] *= (d[v][di]+1)/2;
    ans[u] += x;
    v = u;
  }
}

int main() {
  int q; n = 1; p[0] = -1;
  scanf("%d",&q);
  rep(i,q+1)rep(j,D) d[i][j+1] = 1;
  rep(qi,q) {
    int ty, v;
    scanf("%d%d",&ty,&v); --v;
    if (ty == 1) {
      p[n] = v;
      v = n++;
      up(v);
    } else {
      printf("%.10f\n",ans[v]);
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 600000;
const int K = 100;
vector <int> bi[N];
int tot, fa[N];
double F[N][K];
void dfs(int p, int j)
{
    if (fa[p] && j < K)
    {
        dfs(fa[p], j + 1);
        F[fa[p]][j] = 1 - (1 - F[fa[p]][j]) / (1 - F[p][j - 1] / 2);
    }
}
int main()
{
    ios :: sync_with_stdio(0);
    cin >> n; tot = 1; F[1][0] = 1;
    for (int i = 1; i <= n; ++ i)
    {
        int opt, x;
        cin >> opt >> x;
        if (opt == 1)
        {
            fa[++ tot] = x;
            dfs(tot, 1); F[tot][0] = 1;
            for (int p = tot, j = 1; fa[p] && j < K; p = fa[p], ++ j)
                F[fa[p]][j] = 1 - (1 - F[fa[p]][j]) * (1 - F[p][j - 1] / 2);
        }
        else
        {
            double res = 0;
            for (int j = 1; j < K; ++ j)
                res += F[x][j];
            cout << setprecision(10) << res << endl;
        }
    }
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) w = ch == '-' ? -1 : 1, ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
const int Max_n = 5e5 + 5;
double f[Max_n][51];
int n;
int top, stk[Max_n];
int cnt, fa[Max_n];
void node_init() {
  for (int i = 0; i <= 50; i++) f[cnt][i] = 1;
}
void dfs(int x, int len) {
  if (!fa[x] || len >= 50) return;
  dfs(fa[x], len + 1);
  f[fa[x]][len + 1] /= (f[x][len] + 1);
}
int main() {
  n = read();
  cnt = 1;
  node_init();
  while (n--) {
    if (read() == 1) {
      fa[++cnt] = read(), node_init();
      dfs(fa[cnt], 0);
      f[fa[cnt]][0] *= 0.5;
      for (int x = fa[cnt], to = 1; fa[x] && to <= 50; to++, x = fa[x])
        f[fa[x]][to] *= (f[x][to - 1] + 1);
    } else {
      double ans = 0;
      int x = read();
      for (int i = 1; i <= 50; i++) ans += (double)i * (f[x][i] - f[x][i - 1]);
      printf("%.6lf\n", ans);
    }
  }
}

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <utility>
#include <vector>

const int M = 60;

double f(double p)
{
    return .5 + .5 * p;
}

int main()
{
    std::vector<double> leaf_probability(M);
    for (int i = 1; i < M; ++ i) {
        leaf_probability[i] = 1.;
    }
    int q;
    scanf("%d", &q);
    std::vector<int> parent;
    std::vector<std::vector<double>> probability;
    parent.push_back(-1);
    probability.push_back(leaf_probability);
    while (q --) {
        int t, v;
        scanf("%d%d", &t, &v);
        v --;
        if (t == 1) {
            int u = parent.size();
            parent.push_back(v);
            probability.push_back(leaf_probability);
            std::vector<int> changes;
            changes.push_back(u);
            for (int i = 1; i < M && changes[i - 1]; ++ i) {
                changes.push_back(parent[changes[i - 1]]);
            }
            for (int i = (int)changes.size() - 1; i >= 2; -- i) {
                probability[changes[i]][i] /= f(probability[changes[i - 1]][i - 1]);
            }
            for (int i = 1; i < (int)changes.size(); ++ i) {
                probability[changes[i]][i] *= f(probability[changes[i - 1]][i - 1]);
            }
        } else {
            double result = 0.;
            for (int i = 1; i < M; ++ i) {
                result += (1. - probability[v][i]);
            }
            printf("%.9f\n", result);
        }
    }
}

#include <bits/stdc++.h>
using namespace std;

const int MAGIC = 50;
typedef double ld;

int q;
int on = 2;
int p[500013];
ld prod[500013][MAGIC];

int main() {
	for (int i=0;i<500013;i++) fill(prod[i],prod[i]+MAGIC,1);
	scanf("%d",&q);
	while (q--) {
		int type, v;
		scanf("%d%d",&type,&v);
		if (type==1) {
			p[on] = v;
			on+=1;
			vector<int> has;
			for (int r=0;r<MAGIC-1;r++) {
				has.push_back(v);
				v = p[v];
			}
			for (int i=MAGIC-2;i>=0;i--) {
				int x = has[i];
				prod[p[x]][i+1]/=(0.5+prod[x][i]/2);
			}
			prod[has[0]][0]/=2;
			for (int i=0;i<MAGIC-1;i++) {
				int x = has[i];
				prod[p[x]][i+1]*=(0.5+prod[x][i]/2);
			}
        } else {
			ld ans = 0;
			for (int i=1;i<MAGIC;i++) {
				ans+=i*(prod[v][i]-prod[v][i-1]);
			}
			printf("%1.9f\n",(double) ans);
		}
	}

	return 0;
}

#include<bits/stdc++.h>

using namespace std;
using DO = double;
const int N = 5e5+10;
const int M = 60;
int a[N];
int fa[N];
DO dp[N][M];
DO t[M], p[M], pw[N];
int crr=1;

void update(int u) {
  fa[++crr]=u;
  a[u]++;
  for(int i=0; i<M; i++) p[i]=1;
  for(int f=0, pre=crr; f<M; f++, pre=u, u=fa[u]) {
    if(!u) break;
    for(int i=0; i<M; i++) t[i]=dp[u][i];
    dp[u][0]=pw[a[u]];
    for(int i=1; i<M; i++) dp[u][i]*=(1+dp[pre][i-1])/(1+p[i-1]);
    for(int i=0; i<M; i++) p[i]=t[i];
  }
}
DO calc(int u) {
  DO ans=0;
  for(int i=1; i<M; i++) ans+=(dp[u][i]-dp[u][i-1])*i;
  return ans;
}
int main() {
#ifdef TRUE
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
  for(int i=0; i<N; i++) for(int j=0; j<M; j++) dp[i][j]=1;
  for(int i=pw[0]=1; i<N; i++) pw[i]=pw[i-1]/2;
  int q;
  cin>>q;
  for(int t, u; q--; ) {
    scanf("%d %d", &t, &u);
    if(t == 1) update(u);
    else printf("%.8lf\n", calc(u));
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAXN=500005,MAXH=50;

int fa[MAXN];
double p[MAXN][MAXH];

int main()
{
	int q;
	scanf("%d",&q);
	int id=1;
	while (q--)
	{
		int op,v;
		scanf("%d%d",&op,&v);
		if (op==1)
		{
			fa[++id]=v;
			double t1=0,t2=1;
			for (int i=1,now=v;i<MAXH&&now;i++,now=fa[now])
			{
				double t=p[now][i];
				p[now][i]=1-(1-p[now][i])/(1-t1/2)*(1-t2/2);
				t1=t;
				t2=p[now][i];
			}
		}
		else
		{
			double ans=0;
			for (int i=1;i<MAXH;i++)
				ans+=p[v][i];
			printf("%.8f\n",ans);
		}
	}
	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 500005;

double F[MAXN][60],Nw[MAXN][60];
int Fa[MAXN],Q,N;

int main()
{
	scanf("%d", &Q);
	N = 1;
	for(int i = 1;i < 60;i ++) F[1][i] = 1;
 	for(int i = 1;i <= Q;i ++)
	{
		int type,u;
		scanf("%d%d", &type, &u);
		if (type == 1)
		{
			++ N;
			Fa[N] = u;
			for(int j = 1;j < 60;j ++) F[N][j] = Nw[N][j] = 1.0;
			for(int j = 1,cr = N;j < 60 && Fa[cr];j ++,cr = Fa[cr])
			{
				if (cr != N) Nw[Fa[cr]][j] = F[Fa[cr]][j] / (F[cr][j - 1] + 0.5 * (1 - F[cr][j - 1])); else
					Nw[Fa[cr]][j] = F[Fa[cr]][j];
				Nw[Fa[cr]][j] *= (Nw[cr][j - 1] + 0.5 * (1 - Nw[cr][j - 1]));
			}
			for(int j = 1,cr = N;j < 60 && Fa[cr];j ++,cr = Fa[cr])
				F[Fa[cr]][j] = Nw[Fa[cr]][j];
		} else
		{
			double ans = 0;
			for(int j = 1;j < 60;j ++) ans += (j - 1) * (F[u][j] - F[u][j - 1]);
			printf("%.10f\n", ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &(x))
#define ld double
const int N = 500005;
const int logN = 38;
ld dp[logN][N], prevdp[logN][N];
int par[N];
int main(){
	int q, type, v, index = 1;
	for(int j = 1; j< logN; j++) dp[j][1] = 1.;
	sd(q);
	while(q--){
		sd(type), sd(v);
		if(type == 1){
			par[++index] = v; int p = v; v = index;
			for(int j = 1; j < logN; j++){
				dp[j][v] = 1.;
				prevdp[j][p] = dp[j][p];
				dp[j][p] *= (0.5 * (1 + dp[j - 1][v]));
			}
			int cnt = 2;
			int temp = par[p]; v = p; p = temp;
			while(p && cnt < logN){
				cnt ++;
				for(int j = 1; j < logN; j++){
					prevdp[j][p] = dp[j][p];
					dp[j][p] *= (1 + dp[j - 1][v]) / (1 + prevdp[j - 1][v]);
				}
				int temp = par[p]; v = p; p = temp;
			}
		}
		else{
			ld exp = 0;
			for(int i = 1; i < logN; i++){
				ld p = dp[i][v] - dp[i - 1][v];
				exp += p * i;
			}
			printf("%.7lf\n", exp - 1.);
		}
	}

}

#include <bits/stdc++.h>

using namespace std;

const int MAX = 80;
const int N = 500010;

double f[N][MAX];
int pr[N];

int main() {
  int tt;
  scanf("%d", &tt);
  int n = 1;
  for (int j = 0; j < MAX; j++) {
    f[n][j] = 1.0;
  }
  while (tt--) {
    int type, v;
    scanf("%d %d", &type, &v);
    if (type == 1) {
      n++;
      pr[n] = v;
      for (int j = 0; j < MAX; j++) {
        f[n][j] = 1.0;
      }
      int t = n;
      double old = 1.0;
      for (int j = 0; j < MAX; j++) {
        if (t == 1) {
          break;
        }
        double new_old = 0.5 * (1 + f[pr[t]][j]);
        f[pr[t]][j] *= 0.5 * (1 + (j == 0 ? 0.0 : f[t][j - 1])) / old;
        old = new_old;
        t = pr[t];
      }
    } else {
      double ans = 0.0;
      for (int j = 0; j < MAX; j++) {
        ans += 1.0 - f[v][j];
      }
      printf("%.17f\n", ans);
    }
  }
  return 0;
}

//  Created by Sengxian on 5/10/16.
//  Copyright (c) 2016年 Sengxian. All rights reserved.
//  Codeforces 674E 数学期望 + dp
#include <bits/stdc++.h>
using namespace std;

inline int ReadInt() {
	static int n, ch;
	n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
	return n;
}

const int MAX_H = 40, maxn = 500000 + 3;
double dp[maxn][MAX_H];
int n = 1, fa[maxn];

int main() {
	int q = ReadInt();
	fill(dp[0], dp[0] + MAX_H, 1.0);
	fa[0] = -1;
	while (q--) {
		int type = ReadInt(), u = ReadInt() - 1;
		if (type == 2) {
			double ans = 0;
			for (int i = 1; i < MAX_H; ++i)
				ans += i * (dp[u][i] - dp[u][i - 1]);
			printf("%.10lf\n", ans);
		} else if (type == 1) {
			fa[n] = u;
			int cur = n++, cnt = 0;
			double last = 1.0, pre = 0, llast;
			fill(dp[cur], dp[cur] + MAX_H, 1.0);
			while (cur != -1 && cnt < MAX_H) {
				if (cnt) {
					llast = dp[cur][cnt - 1];
					dp[cur][cnt - 1] /= (last / 2 + 0.5);
					dp[cur][cnt - 1] *= (pre / 2 + 0.5);
					pre = dp[cur][cnt - 1];
					last = llast;
				}
				cnt++;
				cur = fa[cur];
			}
		} else assert(false);
	}
	return 0;
}

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define MAXN 500010
typedef long long LL;
const LL mo=1e9+7;
typedef pair<double,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int n,deg[MAXN],dep[MAXN],father[MAXN],gpt;
double dp[MAXN][55],sum[MAXN][55],dk[MAXN];
signed main(){
	read(n);dk[0]=1;gpt=2;
	for(int i=1;i<=n;i++)dk[i]=dk[i-1]/2.0;
	for(int i=0;i<=50;i++)sum[1][i]=dp[1][i]=1.0;
	for(int i=1;i<=n;i++){
		int opt,x;read(opt);read(x);
		if(opt==1){
			int me=gpt;gpt++;father[me]=x;
			deg[x]++;dep[me]=dep[x]+1;
			for(int i=0;i<=50;i++)sum[me][i]=dp[me][i]=1;
			for(int cur=x;cur&&dep[me]-dep[cur]<=50;cur=father[cur]){
				if(father[cur])
					for(int i=0;i<=50;i++)
						dp[father[cur]][i]/=((sum[cur][i]+1.0)/2.0);
					sum[cur][0]=dk[deg[cur]];dp[father[cur]][0]*=((sum[cur][0]+1.0)/2.0);
				for(int i=1;i<=50;i++){
					double tmp=(i==1)?dp[cur][0]-sum[cur][0]:dp[cur][i-1]-dp[cur][i-2];
					sum[cur][i]=sum[cur][i-1]+tmp;dp[father[cur]][i]*=((sum[cur][i]+1.0)/2.0);
				}
			}
		}
		else{
			double ans=0;
			for(int i=1;i<=50;i++)
				ans+=(sum[x][i]-sum[x][i-1])*i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

#define ll long long
#define inf 1e9
#define eps 1e-8
#define md
#define N 500010
using namespace std;

const int D=60;
double f[N][D+5];
int fa[N];
void dfs(int x,int dep,double p)
{
	if (!x||dep>D) return;
	double t=f[x][dep];
	f[x][dep]*=p;
	dfs(fa[x],dep+1,(f[x][dep]+1)/(t+1));
}

int main()
{
	int n=1,tt; for (int i=0;i<=D;i++) f[n][i]=1;
	scanf("%d",&tt);
	while (tt--)
	{
		int ty,x;
		scanf("%d%d",&ty,&x);
		if (ty==1)
		{
			n++; fa[n]=x;
			for (int i=0;i<=D;i++) f[n][i]=1;
			dfs(fa[n],0,0.5);
		}
		else
		{
			double ans=0;
			for (int i=1;i<=D;i++) ans+=(f[x][i]-f[x][i-1])*i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=58;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}

			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				ps[i][0] = sum[now][0];
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					ps[i][j] = sum[now][j];
					//if(ps[i-1][j-1]>1e-25)
					if(i!=1)
						sum[now][j]/=(0.5+ps[i-1][j-1]/2);
					sum[now][j]*=(0.5+sum[prev][j-1]/2);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			ans+=(M+1)*(1-sum[v][M]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 500007;
const int MAX2 = 207;
const int BASE = 1000000000;
const int CNT = 500;
const int MOD = 1000000007;

double dp[MAX][107];

int p[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);

	int n = 1;
	p[0] = -1;

	FOR(i,0,107)
	{
		dp[0][i] = 1;
	}

	int q;
	cin >> q;
	FOR(qq,0,q)
	{
		int t;
		scanf("%d" , &t);
		if (t == 1)
		{
			int par;
			scanf("%d" , &par);
			--par;
			int v = n;
			p[v] = par;
			++ n;
			FOR(j,0,107)
			{
				dp[v][j] = 1;
			}
			double prevV = dp[par][0];
			dp[par][0] *= 0.5;
			int j = 1;
			while (p[par] != -1 && j <= 102)
			{
				int pp = p[par];
				double pV = dp[pp][j];
				dp[pp][j] /= (0.5 + 0.5 * prevV);

				prevV = pV;
				dp[pp][j] *= (0.5 + 0.5 * dp[par][j - 1]);
				par = pp;
				++j;
			}

		}
		else
		{
			int v;
			scanf("%d" , &v);
			--v;
			double res = 0;

			FOR(i,1,100)
			{
				res += (dp[v][i] - dp[v][i - 1]) * i;
			}
			printf("%.10f\n" , res);
		}
	}

    return 0;
}

#include <cstdio>
using namespace std;

const int maxn = 500050, maxh = 65;
int q, curr = 1, par[maxn];
double prob[maxn][maxh], prev[maxn][maxh];

void append(int i){
	curr++;

	par[curr] = i;
	prob[curr][0] = 1.0;

	int h = 1, y = curr, x = par[curr];
	double bez;

	while(x != -1 && h < maxh){
		bez = (prob[x][h] - 0.5 * prev[y][h - 1]) / (1.0 - 0.5 * prev[y][h - 1]);
		prev[x][h] = prob[x][h];
		prob[x][h] = bez + (1.0 - bez) * 0.5 * prob[y][h - 1];

		y = x;
		x = par[x];
		h++;
	}
}

double calc(int i){
	double ret = 0.;

	for(int h = 1; h < maxh - 1; h++)
		ret += 1. * h * (prob[i][h] - prob[i][h + 1]);

	return ret;
}

int main(){
	par[1] = -1;
	prob[1][0] = 1.0;

	scanf("%d", &q);

	int id, x;
	while(q--){
		scanf("%d %d", &id, &x);

		if(id == 1)
			append(x);
		else
			printf("%.10f\n", calc(x));
	}

	return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef double db;
const int MAXN=500005;
const int MAXH=60;
vector<db>p[MAXN];
int fa[MAXN],stk[MAXH+5],top;
int main()
{
    int q,n=0;
    p[++n]=vector<db>(MAXH+1,1),p[n][0]=0;
    scanf("%d",&q);
    while(q--)
    {
        int ty,v;
        scanf("%d%d",&ty,&v);
        if(ty==1)
        {
            p[++n]=vector<db>(MAXH+1,1),p[n][0]=0;
            fa[n]=v;
            top=0;
            for(int i=n,j=0;i>0 && j<MAXH;i=fa[i],j++)
                stk[top++]=i;
            for(int i=top-1;i>1;i--)
                p[stk[i]][i]/=(1+p[stk[i-1]][i-1])/2;
            for(int i=1;i<top;i++)
                p[stk[i]][i]*=(1+p[stk[i-1]][i-1])/2;
        }
        else
        {
            db res=0;
            for(int i=0;i<MAXH;i++)
                res+=i*(p[v][i+1]-p[v][i]);
            printf("%.10f\n",res);
        }
    }
    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iostream>
#include <set>
#include <fstream>
#include <string>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
#define FOR(i,s,e) for (int i=(s); i<(e); i++)
#define FOE(i,s,e) for (int i=(s); i<=(e); i++)
#define FOD(i,s,e) for (int i=(s); i>=(e); i--)
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define LL long long
#define ULL unsigned long long
#define eps 1e-9
#define pi acos(-1.0)
LL max(LL a,LL b){if (a>b){return a;} else {return b;}}
LL min(LL a,LL b){if (a<b){return a;} else {return b;}}

#define K 600001

int cnt[K], q1[K], q2[K], h, par[K], n;
double sum[K][54], nw[K][54];

int co, q;

double f(int a, int b, int op){
	if (op == 2) return nw[a][b]; else return sum[a][b];
	double ret = (op==2?nw[a][b]:sum[a][b]);
	if (b != 0) ret -= (op==2?nw[a][b]:sum[a][b - 1]);
	return ret;
}

void recalc(int u, int w, int lv, int nc){
	//printf("recalc %d %d %d %d\n", u, w, lv, nc);
	if (u == 0 || lv >= 44) return;
	FOE(j, lv, lv){
		nw[u][j] = sum[u][j];
		if (nc && j == 0) nw[u][j] /= (double)2.00;
		if (j != 0){
	//		if (j <= n) printf("rebuild %d, layer %d: cof is %.9f / (1/2*(1+%.9f)) * (1/2*(1+%.9f))\n",
	//					u, j, sum[u][j], f(w, j - 1, 1), f(w, j - 1, 2));
			nw[u][j] = sum[u][j] / (1.00 / 2 * (1.00 + f(w, j - 1, 1)))
				* (1.00 / 2 * (1.00 + f(w, j - 1, 2)));
		}
	}
	recalc(par[u], u, lv + 1, 0);
	FOE(j, lv, lv) sum[u][j] = nw[u][j];
}

int main(){
	scanf("%d", &q);
	n = 1;
	FOE(i, 0, 44) sum[1][i] = 1.000;
	FOE(i, 1, q){
		scanf("%d%d", &q1[i], &q2[i]);
		if (q1[i] == 1) {
			n++; par[n] = q2[i];
			FOE(j, 0, 44) nw[n][j] = sum[n][j] = 1.00;
			recalc(q2[i], n, 0, 1);
		} else {
			double ret = 0.00;
			FOE(j, 1, 44) {
//				printf("diff is %.9f - %.9f\n",
//						sum[q2[i]][j], sum[q2[i]][j - 1]);
				ret = (ret + (double)j * (sum[q2[i]][j] - sum[q2[i]][j - 1]));
			}
			printf("%.12lf\n", ret);
		}
	}

    return 0;
}

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <bitset>
#include <queue>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define LL long long
#define ULL unsigned long long
#define eps 1e-9
#define N (500000 + 10)
#define M (400000 + 10)
#define pii pair<int,int>
#define MP make_pair
#define inf 0x3f3f3f3f
#define lson ll, md, ls
#define rson md + 1, rr, rs
#define mod 1000000007

double ans[N][66];
int fa[N];
int tot;
const int Max = 50;
int main() {
	int n;
	scanf("%d", &n);
	tot = 1;
	ans[0][0] = 0;
	for(int i = 1; i<= Max; ++i)
		ans[0][i] = 1;
	while(n--) {
		int op, u;
		scanf("%d%d", &op, &u);
		--u;
		if(op == 2) {
			double ret = 0;
			for(int i = 1; i <= Max; ++i)
				ret += (1 - ans[u][i]);
			printf("%.10lf\n", ret);
		}
		else {
			fa[tot] = u;
			ans[tot][0] = 0;
			for(int i = 1; i <= Max; ++i) ans[tot][i] = 1;
			double tmp = 0.5;
			double pre = 0, last = 1;;
			int v = tot;
			for(int i = 1; i <= Max; ++i) {
				pre = ans[u][i];
				ans[u][i] /= (0.5 * last + 0.5);
				ans[u][i] *= (0.5 * ans[v][i-1] + 0.5);
				last = pre;
				tmp *= 0.5;
				if(!u) break;
				v = u;
				u = fa[u];
			}
			++tot;
		}
	}
}

#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 500005, lim = 40;
int q, n = 1, p[MX];
ld dp[MX][lim];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(8);

	forn (i, MX) forn (j, lim) dp[i][j] = 1;

	cin >> q;
	while (q--) {
		int op, v;
		cin >> op >> v;

		if (op == 1) {
			p[++n] = v;

			ld aux = dp[v][0];
			dp[v][0] *= 0.5;

			int i = 1;
			while (v && i < lim) {
				ld t = dp[p[v]][i];
				dp[p[v]][i] *= (1 + dp[v][i - 1]) / (1 + aux);
				aux = t;
				v = p[v];
				i++;
			}
		} else {
			ld res = lim;

			forn (j, lim)
				res -= dp[v][j];

			cout << res << endl;
		}
	}

	return 0;
}

#include <bits/stdc++.h>

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 5e5 + 100;

int Q, fa[Maxn];
double f[61][Maxn];

inline void dfs_div (int x, int tot)
{
	if (tot == 60 || !fa[x]) return ;
	dfs_div (fa[x], tot + 1);
	f[tot + 1][fa[x]] /= 0.5 * (f[tot][x] + 1);
}

inline void dfs_mul (int x, int tot)
{
	if (tot == 60 || !fa[x]) return ;
	f[tot + 1][fa[x]] *= 0.5 * (f[tot][x] + 1);
	dfs_mul (fa[x], tot + 1);
}

inline void Solve ()
{
	int now = 1;
	for (int i = 0; i <= 60; ++i) f[i][1] = 1;

	while (Q--)
	{
		int op = read<int>(), x = read<int>();
		if (op == 1)
		{
			fa[++now] = x;
			for (int i = 0; i <= 60; ++i) f[i][now] = 1;

			dfs_div (fa[now], 0);
			f[0][fa[now]] *= 0.5;
			dfs_mul (fa[now], 0);
		}
		else
		{
			double ans = 0;
			for (int i = 1; i <= 60; ++i) ans += (f[i][x] - f[i - 1][x]) * i;
			printf("%.10lf\n", ans);
		}
	}
}

inline void Input ()
{
	Q = read<int>();
}

int main()
{

#ifndef ONLINE_JUDGE
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define re register
#define il inline
#define rep(i,a,b) for(re int i=(a);i<=(b);++i)
const int N =500005;
int Q,n;
int fa[N];
typedef double db;
db f[N][65],ans;
const db eps =1e-8;
void find(int u,int j,db pre){
	if(!fa[u]||j>60)return;
	db tmp=f[fa[u]][j+1];
	f[fa[u]][j+1]*=(f[u][j]+1)/(pre+1);
	find(fa[u],j+1,tmp);
}
int main(){
	scanf("%d",&Q);
	int op,ff;n=1;
	rep(i,0,60)
	f[1][i]=1;
	while(Q--){
		scanf("%d%d",&op,&ff);
		if(op==1){
			fa[++n]=ff;
			rep(i,0,60)
			f[n][i]=1;
			f[ff][0]*=0.5;
			find(ff,0,f[ff][0]*2);
		}
		else{
			ans=0;
			rep(i,1,60){
				ans+=(f[ff][i]-f[ff][i-1])*i;
			}
			printf("%.12lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(x) (int) ((x).size())
#define forn(i, n) for (int i = 0; (i) < (n); ++i)
#define fornr(i, n) for (int i = (n) - 1; (i) >= 0; --i)
#define forab(i, a, b) for (int i = (a); (i) < (b); ++i)
#define forba(i, a, b) for (int i = (b) - 1; (i) >= (a); --i)
#define forit(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)
#endif

#ifdef _WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef double dbl;

#define FNAME ""

const int MAX = 50, MAXN = 5e5 + 10;

int up[MAXN];
dbl dp[MAXN][MAX], old[MAX], old2[MAX];

int main()
{
#ifdef LOCAL
	freopen(FNAME".in", "r", stdin);
	freopen(FNAME".out", "w", stdout);
#endif

	int q;
	scanf("%d", &q);
	int cur = 1;
	dp[0][0] = 1;
	forn (qq, q)
	{
		int t, v;
	 	scanf("%d%d", &t, &v);
	 	v--;
	 	if (t == 1)
	 	{
	 		up[cur++] = v;
	 		int u = v, last = cur;
	 		dp[cur][0] = 1;
	 		//old[cur][0] = 1;
	 		forn (h, MAX)
	 			old[h] = 0;
	 		for (int h = 1; h < MAX; h++)
	 		{
	 			old2[0] = dp[u][0];
	 		    forab (j, 1, h + 1)
	 		    {
	 		        old2[j] = dp[u][j];
	 		    	dp[u][j] = 1 - (1 - dp[u][j]) / (2 - old[j - 1]) * (2 - dp[last][j - 1]);
	 			}
	 			forn (j, h + 1)
	 				old[j] = old2[j];
	 			if (u == 0)
	 				break;
	 			last = u;
	 			u = up[u];
	 		}
		}
		else
		{
			ld ans = 0;
		 	forab (i, 1, MAX)
		 		ans += dp[v][i];
			printf("%.20f\n", (double) ans);
		}
	}
	cerr << clock() * 1. / CLOCKS_PER_SEC << endl;
	//while(1);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

constexpr int MAX_H = 60;

double dp[500005][MAX_H + 1];
int parent[500005];

void add(int p, int t)
{
	parent[t] = p;
	double old = 0.0;
	int h = 0;
	dp[t][0] = 1;

	// dp[t][k] :
	// 1 - PI(1 - dp[x][k - 1] * 1/2)

	for (;;)
	{
		h++;
		if (p == 0 || h >= MAX_H) break;

		double old2 = dp[p][h];
		double pi = 1 - dp[p][h];
		pi = pi / (1 - old / 2) * (1 - dp[t][h - 1] / 2);
		dp[p][h] = 1 - pi;
		old = old2;
		t = p;
		p = parent[p];
	}
}

double calc(int t)
{
	double ret = 0;
	for (int i = 1; i < MAX_H; i++)
	{
		ret += (dp[t][i] - dp[t][i + 1]) * i;
	}
	return ret;
}

int main()
{
	int q;
	scanf("%d",&q);
	int last_idx = 1;
	dp[1][0] = 1;

	for (int i = 0; i < q; i++)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		if (a == 1)
		{
			add(b, ++last_idx);
		}
		else
		{
			printf("%.9f\n", calc(b));
		}
	}
}

#include <bits/stdc++.h>
using namespace std;

const int mxn=70,MX=501000;
double dp[MX][mxn+5];
int n,x,ty,v,p[MX];
int main() {
	scanf("%d",&n);
	int x=1;
	for ( int i = 1 ;i < mxn ; i ++ )
		dp[x][i]=1;
	for ( int i = 0 ;i < n ;i ++ ){
		scanf("%d%d",&ty,&v);
		if (ty==2) {
			double ret=0;
			for ( int j = 1 ;j < mxn ; j ++ )  ret+=1-dp[v][j];
			printf("%.10f\n",ret);
		}
		else {
			x++; p[x]=v;
			for ( int j = 1 ;j <mxn ;j ++)  dp[x][j]=1;
			v=x;
			double prv=1;
			for ( int j = 1 ; j< mxn ; j ++ ) {
				if (p[x]==0) break;
				double crv=0.5*(1+dp[p[x]][j]);
				dp[p[x]][j]/=prv;
				dp[p[x]][j]*=0.5*(1+dp[x][j-1]);
				prv=crv; x=p[x];
			}
			x=v;
		}
	}
	return 0;

}

#define _ijps 0
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:667772160")
#include <iostream>
#include <cmath>
#include <vector>
#include <time.h>
#include <map>
#include <set>
#include <deque>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <string>
#include <fstream>
#include <complex>
#include <assert.h>
#include <list>
#include <cstring>
using namespace std;

#define name ""
typedef unsigned long long ull;
typedef long long ll;
#define mk make_pair
#define forn(i, n) for(ll i = 0; i < (ll)n; i++)
#define fornn(i, q, n) for(ll i = ( ll)q; i < (ll)n; i++)
#define times clock() * 1.0 / CLOCKS_PER_SEC

struct __isoff{
    __isoff(){
        if (_ijps)
            freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);//, freopen("test.txt", "w", stderr);
        //else freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);
        //ios_base::sync_with_stdio(0);
        srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
        //srand(time(0));
    }
    ~__isoff(){
        //if(_ijps) cout<<' '<<times<<'\n';
    }
} __osafwf;
const ull p1 = 123123;
const ull p2 = 12321;
const double eps = 1e-6;
const double pi = acos(-1.0);

const ll inf = 1e18 + 7;
const int infi = 1e9 + 7;
const ll dd = 5e5 + 7;
const ll maxN = 1e5 + 7;
const ll sh = 4501;
const ll mod = 1e9 + 7;
const ll mod2 = 100003;

const int cs = 40;
int g = 1;

double dp[dd][cs];
double pv[dd][cs];
double D[cs][cs];

int G[dd];
int T[cs];

void upd(int v){
	int g = v;
	int tf = 0;
	forn(i, cs){
		if(g == -1){
			break;
		}
		tf++;
		T[i] = g;
		forn(j, cs){
			D[i][j] = dp[g][j];
		}
		g = G[g];
	}
	fornn(i, 1, tf){
		int v = T[i];
		if(i == 1){
			pv[v][0] *= 0.5;
		}
		double z = 0.5, e = 0.5;
		fornn(j, 1, cs){
			z += dp[T[i - 1]][j - 1] / 2;
			e += D[i - 1][j - 1] / 2;
			pv[v][j] *= z / e;
		}
		for(int j = cs - 1; j > 0; j--){
			dp[v][j] = pv[v][j] - pv[v][j - 1];
		}
		dp[v][0] = pv[v][0];
	}
}

int main(){
	int n;
	cin >> n;
	G[0] = -1;
	forn(i, n){
		forn(j, cs){
			pv[i][j] = 1;
		}
		dp[i][0] = 1;
	}
	forn(i, n){
		int t, v;
		scanf("%d%d", &t, &v);
		v--;
		if(t == 1){
			G[g] = v;
			upd(g);
			g++;
		}
		else{
			double res = 0;
			forn(i, cs){
				res += i * (dp[v][i]);
			}
			printf("%0.10f\n", res);
		}
	}
}

//  Created by Sengxian on 5/10/16.
//  Copyright (c) 2016年 Sengxian. All rights reserved.
//  Codeforces 674E 数学期望 + dp
#include <bits/stdc++.h>
using namespace std;

inline int ReadInt() {
	static int n, ch;
	n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
	return n;
}

const int MAX_H = 32, maxn = 500000 + 3;
double dp[maxn][MAX_H];
int n = 1, fa[maxn];

int main() {
	int q = ReadInt();
	fill(dp[0], dp[0] + MAX_H, 1.0);
	fa[0] = -1;
	while (q--) {
		int type = ReadInt(), u = ReadInt() - 1;
		if (type == 2) {
			double ans = 0;
			for (int i = 1; i < MAX_H; ++i)
				ans += i * (dp[u][i] - dp[u][i - 1]);
			printf("%.10lf\n", ans);
		} else if (type == 1) {
			fa[n] = u;
			int cur = fa[n], cnt = 1;
			double last = 1.0, pre = 0, llast;
			fill(dp[n], dp[n] + MAX_H, 1.0);
			while (cur != -1 && cnt < MAX_H) {
				llast = dp[cur][cnt - 1];
				dp[cur][cnt - 1] /= (last / 2 + 0.5);
				dp[cur][cnt - 1] *= (pre / 2 + 0.5);
				pre = dp[cur][cnt - 1];
				last = llast;
				cnt++;
				cur = fa[cur];
			}
			n++;
		} else assert(false);
	}
	return 0;
}

#include <bits/stdc++.h>

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define in(x) int (x); input((x));
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)

typedef int itn;

//#define next next12345
//#define prev prev12345
#define left lefdsf232
#define right rig43783
#define x1 x12345
#define y1 y12345

using namespace std;

template<typename T>
T gcd(T x, T y) {
    while (y > 0) {
        x %= y;
        swap(x, y);
    }
    return x;
}

template<class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<class _T>
inline _T sqr(const _T &x) {
    return x * x;
}

template<class _T>
inline string tostr(const _T &a) {
    ostringstream os("");
    os << a;
    return os.str();
}

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const ld PI = 3.1415926535897932384626433832795L;

template<typename T>
inline void input(T &a) {
    static int ed;
    a = 0;
    while (!isdigit(ed = getchar()) && ed != '-') { }
    char neg = 0;
    if (ed == '-') {
        neg = 1;
        ed = getchar();
    }
    while (isdigit(ed)) {
        a = 10 * a + ed - '0';
        ed = getchar();
    }
    if (neg) a = -a;
}

template<typename T = int>
inline T nxt() {
    T res;
    input(res);
    return res;
}

void myassert(bool v) {
    assert(v);
    //cout << "FAIL\n";
    //exit(0);
}

mt19937 generator;

bool check(int v) {
    if (v < 2) return false;
    for (int i = 2; i * i <= v; ++i) {
        if (v % i == 0) {
            return false;
        }
    }
    return true;
}

long long pw(long long a, long long n, long long m) {
    ll res = 1;
    while (n) {
        if (n & 1ll) {
            res = res * a % m;
        }
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

long long inv(long long a, long long p) {
    long long res = 1;
    while (a > 1) {
        res = res * (p - p / a) % p;
        a = p % a;
    }
    return res;
}
vector <int> p;

const int M = 60;

double  dp[1 << 19][M];

void solve(int test) {
    p.resize(1, -1);
    int q = nxt();
    vector <pair <int, int> > r;

    while (q--) {
        int t = nxt();
        int v = nxt() - 1;
        r.pb(mp(t, v));
        if (t == 1) {
            p.pb(v);
        }
    }
    forn(i, M) dp[0][i] = 1;

    int sz = 1;
    for (auto v : r) {
        if (v.x == 1) {
            int cur = sz++;
            forn(i, M) dp[cur][i] = 1;
            int pr = cur;
            cur = p[cur];
            int h = 0;
            double old[M][M];
            while (cur != -1 && h < M) {
                memcpy(old[h], dp[pr], sizeof(dp[pr]));
                for (int j = h; j < M; ++j) {
                    if (pr != sz - 1) dp[cur][j] /= (0.5 + 0.5 * (j ? old[h][j - 1] : 0));
                    dp[cur][j] *= (0.5 + 0.5 * (j ? dp[pr][j - 1] : 0));
                }
                pr = cur;
                cur = p[cur];
                ++h;
            }
        } else {
            ld ans = 0;
            for (int i = 0; i < M; ++i) {
                ans += 1 - dp[v.y][i];
            }
            printf("%.10f\n", (double)ans);
        }
    }
}

int main(int argc, char ** argv) {

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    #define fname "sequence"
    //freopen(fname".in", "r", stdin);
    //freopen(fname".out", "w", stdout);
#endif
    //ios_base::sync_with_stdio(false);
//    pre();
    int t = 1;

#ifdef LOCAL
#else
#endif
    int c = 0;

    while (t--) {
        solve(++c);
    }

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &(x))
#define ld double
const int N = 500005;
const int logN = 35;
ld dp[logN][N], prevdp[logN][N];
int par[N];
int main(){
	int q, type, v, index = 1;
	for(int j = 1; j< logN; j++) dp[j][1] = 1.;
	sd(q);
	while(q--){
		sd(type), sd(v);
		if(type == 1){
			par[++index] = v; int p = v; v = index;
			for(int j = 1; j < logN; j++){
				dp[j][v] = 1.;
				prevdp[j][p] = dp[j][p];
				dp[j][p] *= (0.5 * (1 + dp[j - 1][v]));
			}
			int cnt = 2;
			int temp = par[p]; v = p; p = temp;
			while(p && cnt < logN){
				cnt ++;
				for(int j = 1; j < logN; j++){
					prevdp[j][p] = dp[j][p];
					dp[j][p] *= (1 + dp[j - 1][v]) / (1 + prevdp[j - 1][v]);
				}
				int temp = par[p]; v = p; p = temp;
			}
		}
		else{
			ld exp = 0;
			for(int i = 1; i < logN; i++){
				ld p = dp[i][v] - dp[i - 1][v];
				exp += p * i;
			}
			printf("%.10lf\n", exp - 1.);
		}
	}

}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#pragma comment (linker, "/STACK:256000000")

using namespace std;

const int maxN = 510000;
const int maxK = 37;
const double eps = 1e-20;

vector < int > g[maxN];
int q;
int n = 1;
int parent[maxN];

double p[maxN][maxK];
double p2[maxN];

void initVertex(int v) {
	for (int i = 0; i < maxK; ++i) {
		p[v][i] = 1.0;
	}
}

void updateVertex(int v, int u, bool add, int length) {
	for (int i = 1; i < maxK && i < length; ++i) {
		double value = 0.5 * (1.0 + p[u][i - 1]);
		if (add) {
			p[v][i] *= value;
		} else {
			p[v][i] /= value;
		}
		if (p[v][i] < eps) {
			p[v][i] = 0.0;
		}
	}

	if (add) {
		p[v][0] = p2[g[v].size()];
	}
}

void addVertex(int v) {
	++n;
	int u = n;

	parent[u] = v;
	g[v].push_back(u);

	int depth = 0;
	vector < int > path;
	path.push_back(u);
	while (v != 0 && depth < maxK) {
		++depth;
		path.push_back(v);
		v = parent[v];
	}

	reverse(path.begin(), path.end());

	for (int i = 0; i + 2 < path.size(); ++i) {
		updateVertex(path[i], path[i + 1], false, path.size() - i);
	}

	initVertex(u);
	for (int i = (int)(path.size()) - 2; i >= 0; --i) {
		updateVertex(path[i], path[i + 1], true, i);
	}
}

double getRes(int v) {
	double res = 0.0;
	for (int i = 1; i < maxK; ++i) {
		double q = p[v][i] - p[v][i - 1];
		res += q * (double)(i);
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	p2[0] = 1.0;
	for (int i = 1; i < maxN; ++i) {
		p2[i] = p2[i - 1] * 0.5;
		if (p2[i] < eps) {
			p2[i] = 0.0;
		}
	}

	scanf("%d", &q);
	initVertex(1);
	for (int i = 0; i < q; ++i) {
		int mode, v;
		scanf("%d%d", &mode, &v);
		if (mode == 1) {
			addVertex(v);
		} else {
			printf("%.10lf\n", getRes(v));
		}
	}

	return 0;
}

#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
typedef double llf;
#define X first
#define Y second

const int MAX = 1<<19, MAXDUB = 40;
const llf GRAN = 1 - (1e-9);

int vr=1;
int par[MAX];
P q[MAX];
llf umn[MAX][MAXDUB];

void Makni(int ja, int ch)
{
  for (int i=1; i<MAXDUB; i++) {
    if (umn[ch][i-1] > GRAN)
      break;
    umn[ja][i] /= (0.5 * umn[ch][i-1] + 0.5);
  }
}

void Stavi(int ja, int ch)
{
  for (int i=1; i<MAXDUB; i++) {
   // if (umn[ch][i-1] > GRAN)
     // break;
    umn[ja][i] *= (0.5 * umn[ch][i-1] + 0.5);
  }
}

void Dodaj(int node)
{
  int tmp = node;
  vector <int> V;

  for (int i=0; i<MAXDUB && node; i++, node=par[node])
    V.push_back(node);
  V.push_back(par[node]);

  for (int i=(int) V.size()-1; i>0; i--)
    Makni(V[i], V[i-1]);

  umn[tmp][0] = 0;

  for (int i=0; i<(int) V.size()-1; i++)
    Stavi(V[i+1], V[i]);
}

int main()
{
  int brq;
  int ind = 1;

  scanf("%d", &brq);

  for (int i=0; i<MAX; i++)
    for (int j=0; j<MAXDUB; j++)
      umn[i][j] = 1;

  umn[0][0] = 0;
  for (int i=0; i<brq; i++) {
    scanf("%d%d", &q[i].X, &q[i].Y); q[i].Y--;
    if (q[i].X == 1) {
      par[ind] = q[i].Y;
      Dodaj(ind++);
    }
    else {
      llf ret = 0;
      for (int j=1; j<MAXDUB; j++)
        ret += 1 - umn[q[i].Y][j];

      printf("%.10lf\n", (double) ret);
    }
  }

  return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

double f[510000][31];
int fa[510000], son[510000];

double pow_mod(double a, int k) {
	double ans = 1.0;
	while(k) {
		if(k & 1) ans *= a;
		a *= a; k /= 2;
	} return ans;
}

int main() {
	int n = 1;
	for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
	int Q = read();
	for(int i = 1; i <= Q; i++) {
		int opt = read(), x = read();
		if(opt == 1) {
			n++; fa[n] = x;
			son[x]++;
			for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
			double last = f[x][0];
			f[x][0] = pow_mod(0.5, son[x]);
			for(int i = 1; i <= 30; i++) {
				if(x == 1) break;
				int u = fa[x];
				double hh = f[u][i];
				f[u][i] /= (0.5 + 0.5 * last);
				f[u][i] *= (0.5 + 0.5 * f[x][i - 1]);
				x = u; last = hh;
			}
		} else {
			double ans = 0.0;
			for(int i = 1; i <= 30; i++) ans += (double)i * (f[x][i] - f[x][i - 1]);
			printf("%.6lf\n", ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500000;
const int MAX_H = 64;

int n, p[MAX_N];
double f[MAX_N][MAX_H];

double ask(int v) {
    double sum = 0.0;
    for (int i = 1; i < MAX_H; ++i) {
        sum += (f[v][i] - f[v][i - 1]) * i;
    }
    return sum;
}

void add(int v) {
    ++n;
    p[n] = v;
    for (int i = 0; i < MAX_H; ++i) {
        f[n][i] = 1.0;
    }
    vector<int> ancestors;
    for (int i = 0, u = n; i < MAX_H && u != -1; ++i, u = p[u]) {
        ancestors.push_back(u);
    }
    for (int i = 2; i < MAX_H && i < (int)ancestors.size(); ++i) {
        f[ancestors[i]][i - 1] /= (1.0 + f[ancestors[i - 1]][ - 2]) / 2.0;
    }
    for (int i = 1; i < MAX_H && i < (int)ancestors.size(); ++i) {
        if (i == 1) {
            f[ancestors[i]][i - 1] *= 1.0 / 2.0;
        } else {
            f[ancestors[i]][i - 1] *= (1.0 + f[ancestors[i - 1]][i - 2]) / 2.0;
        }
    }
}

int main() {
    int q;
    cin >> q;

    n = 0;
    p[n] = -1;
    for (int i = 0; i < MAX_H; ++i) {
        f[n][i] = 1.0;
    }

    for (int i = 0; i < q; ++i) {
        int type, v;
        cin >> type >> v;
        --v;
        if (type == 1) {
            add(v);
        } else {
            cout << setprecision(12) << ask(v) << endl;
        }
    }

    return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=45;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}
			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				for(int j=0; j<=i; j++) ps[i][j] = sum[now][j];
				prev = now;
				now = parent[now];
			}

			prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					if(ps[i-1][j-1]>0.00000000001)
					sum[now][j]/=(0.5+0.5*ps[i-1][j-1]);
					sum[now][j]*=(0.5+0.5*sum[prev][j-1]);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <memory.h>

using namespace std;

int t[500005], v[500005];
vector<int> g[500005];

const int MAXP = 17;
const int N = MAXP;

struct SegmentTree {
  SegmentTree(int _n = 0) : n(_n) {
    init(_n);
  }

  void init(int _n) {
    n = _n;
    tree = vector<vector<double>>(n + 1, vector<double>(N, 1.0));

    // tree[n + 1] = vector<double>(N, 0);
    // tree[n + 1][0] = 1.0;
  }

  void update(int pos, const vector<double> &v, int where) {
    // for (int i = 1; i < v.size(); ++i)
    //   v[i] += v[i - 1];

    // for (int i = 0; i < tree[pos].size(); ++i) {
    //   tree[n][i] /= tree[pos][i];
    // }
    // for (int i = 0; i < v.size(); ++i) {
    //   tree[n][i] *= v[i];
    // }

    for (int i = where; i < tree[pos].size() && i <= where; ++i) {
      tree[n][i] /= tree[pos][i];
    }
    for (int i = where; i < v.size() && i <= where; ++i) {
      tree[n][i] *= v[i];
    }

    // for (int i = 0; i < N; ++i) {
    //   tree[n + 1][i] = tree[n][i] - (i > 0 ? tree[n][i - 1] : 0);
    // }
    tree[pos][where] = v[where];
  }

  vector<double>& get() {
    return tree[n];
  }

  int n;
  vector<vector<double>> tree;
};

SegmentTree Q[500005];

int par[500005], POS[500005];

int main() {
  Q[0].init(500000);
  int q;
  scanf("%d", &q);
  int cnt = 1;
  memset(par, -1, sizeof(par));
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &t[i], &v[i]); --v[i];
    if (t[i] == 1) {
      POS[cnt] = g[v[i]].size();
      g[v[i]].push_back(cnt);
      par[cnt] = v[i];
      ++cnt;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    Q[i].init(g[i].size());
  }

  cnt = 1;
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      vector<double> cur(N, 0);
      cur[0] = 0.5; cur[1] = 1.0;
      int x = cnt, it = 0, where = 0;
      while (par[x] != -1 && it < N) {
        ++it;
        // cout << x << "  " << par[x] << "  " << POS[x] << endl;
        Q[par[x]].update(POS[x], cur, where); ++where;
        x = par[x];
        // cur = Q[x].get();
        if (where < N)
          cur[where] = Q[x].get()[where - 1] * 0.5 + 0.5;
        // vector<double> tmp(1, 0.5);
        // for (int i = 0; i < cur.size() && i < N; ++i) {
        //   tmp.push_back(0.5 * cur[i] + 0.5);
        // }
        // cur = tmp;
      }
      ++cnt;
    } else {
      double ans = 0;
      vector<double> X = Q[v[i]].get();
      for (int j = 1; j < X.size(); ++j) {
        ans += j * (X[j] - X[j - 1]);
      }
      printf("%.10lf\n", ans);
    }
  }

  // {
  //   int N = 1000, C = 1;
  //   cout << N << endl;
  //   for (int i = 0; i < N; ++i) {
  //     int T = (rand() & 1) + 1;
  //     cout << T << " " << (rand() % C) + 1 << endl;
  //     if (T == 1) ++C;
  //   }
  // }

  return 0;
}

#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<vector<ll> > mat;

const int N = 5e5 + 10;
const ll INF = 1e17 + 1;
const ll MOD = 1e9 + 7;
const int M = 1e6 + 10;
const int H = 40;

ld pref[N][H + 1];
int par[N];
vector<int> g[N];
ld pows[H + 1];
ld mults[N][H + 1];

void recalc(int v, int height, int last) {
    if (!height) {
        fill(pref[v], pref[v] + H + 1, 1);
        fill(mults[v], mults[v] + H + 1, 1);
    }
    if (g[v].size()) {
        int u = last;
        if (height == 1) {
            if (par[v] != -1)
                mults[par[v]][0] /= ((1 + pref[v][0]) / 2);
            pref[v][0] = pows[g[v].size()];
            if (par[v] != -1)
                mults[par[v]][0] *= ((1 + pref[v][0]) / 2);
        }
        else {
            for (int h = height - 1; h <= height - 1; h++) {
                if (par[v] != -1)
                    mults[par[v]][h] /= ((1 + pref[v][h]) / 2);
                ld tmp = (mults[v][h - 1] -
                    (h - 1 > 0 ? mults[v][h - 2] : pows[g[v].size()]));
                pref[v][h] = tmp + (h - 1 >= 0 ? pref[v][h - 1] : 0);
                if (par[v] != -1)
                    mults[par[v]][h] *= ((1 + pref[v][h]) / 2);
            }
        }
    }
}

void solve() {
    int q;
    cin >> q;
    fill(par, par + q + 1, -1);
    pows[0] = 1;
    for (int i = 1; i <= H; i++)
        pows[i] = pows[i - 1] / 2.0;

    recalc(0, 0, -1);

    int curInd = 1;
    for (int i = 0; i < q; i++) {
        int typ, v;
        cin >> typ >> v;
        v--;
        if (typ == 1) {
            par[curInd] = v;
            g[v].pb(curInd);

            int u = curInd;
            int lastu = -1;
            for (int i = 0; i < H; i++) {
                recalc(u, i, lastu);
                lastu = u;
                if (par[u] != -1) {
                    u = par[u];
                } else {
                    break;
                }
            }
            curInd++;
        } else {
            ld ans = 0;
            for (int i = 0; i <= H; i++) {
                ans += i * (pref[v][i] - (i ? pref[v][i - 1] : 0));
            }
            cout << fixed << setprecision(12) << ans << "\n";
        }

    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("a.in", "r", stdin);
    int tst = 1;
    while (tst--)
        solve();
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#pragma comment (linker, "/STACK:256000000")

using namespace std;

const int maxN = 510000;
const int maxK = 35;
const double eps = 1e-20;

vector < int > g[maxN];
int q;
int n = 1;
int parent[maxN];

double p[maxN][maxK];
double p2[maxN];

void initVertex(int v) {
	for (int i = 0; i < maxK; ++i) {
		p[v][i] = 1.0;
	}
}

void updateVertex(int v, int u, bool add) {
	for (int i = 1; i < maxK; ++i) {
		double value = 0.5 * (1.0 + p[u][i - 1]);
		if (add) {
			p[v][i] *= value;
		} else {
			p[v][i] /= value;
		}
		if (p[v][i] < eps) {
			p[v][i] = 0.0;
		}
	}

	if (add) {
		p[v][0] = p2[g[v].size()];
	}
}

void addVertex(int v) {
	++n;
	int u = n;

	parent[u] = v;
	g[v].push_back(u);

	int depth = 0;
	vector < int > path;
	path.push_back(u);
	while (v != 0 && depth < maxK) {
		++depth;
		path.push_back(v);
		v = parent[v];
	}

	reverse(path.begin(), path.end());

	for (int i = 0; i + 2 < path.size(); ++i) {
		updateVertex(path[i], path[i + 1], false);
	}

	initVertex(u);
	for (int i = (int)(path.size()) - 2; i >= 0; --i) {
		updateVertex(path[i], path[i + 1], true);
	}
}

double getRes(int v) {
	double res = 0.0;
	for (int i = 1; i < maxK; ++i) {
		double q = p[v][i] - p[v][i - 1];
		res += q * (double)(i);
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	p2[0] = 1.0;
	for (int i = 1; i < maxN; ++i) {
		p2[i] = p2[i - 1] * 0.5;
		if (p2[i] < eps) {
			p2[i] = 0.0;
		}
	}

	scanf("%d", &q);
	initVertex(1);
	for (int i = 0; i < q; ++i) {
		int mode, v;
		scanf("%d%d", &mode, &v);
		if (mode == 1) {
			addVertex(v);
		} else {
			printf("%.10lf\n", getRes(v));
		}
	}

	return 0;
}

#include <bits/stdc++.h>
#define ld long double
#define ll long long
using namespace std;
template <typename T> void chkmax(T &x, T y) {x = x > y ? x : y;}
template <typename T> void chkmin(T &x, T y) {x = x > y ? y : x;}
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); x *= f;
}
const int N = 500010;
ld f[N][70]; int fa[N];
int main() {
	int q, tot = 1; read(q);
	for (int i = 0; i <= 65; i++) f[1][i] = 1;
	while (q--) {
		int op, x; read(op), read(x);
		if (op == 1) {
			fa[++tot] = x;
			for (int i = 0; i <= 65; i++) f[tot][i] = 1;
			ld tx = f[x][0], ty; f[x][0] *= 0.5;
			for (int i = 1; i <= 65 && fa[x]; i++, x = fa[x]) {
				ty = f[fa[x]][i];
				f[fa[x]][i] /= 0.5 + 0.5 * tx;
				f[fa[x]][i] *= 0.5 + 0.5 * f[x][i - 1];
				tx = ty;
			}
		} else {
			ld sum = 0;
			for (int i = 1; i <= 65; i++) sum += (f[x][i] - f[x][i - 1]) * i;
			cout << sum << '\n';
		}
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 5e5 + 10;
const int MAGIC = 30;

int q, n, par[MAXN];
ld p[MAGIC][MAXN];

void go(int v, int u, int cur = 0){
	if (cur == MAGIC)	return;
	if (v == -1)	return;
	go(par[v], v, cur + 1);

	if (~v)
		for (int w = 1; w < MAGIC; w++)
			p[w][v] /= (0.5 + 0.5 * p[w - 1][u]);
}

int main(){
	//cout << sizeof(p) << endl;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	cin >> q;
	for (int i = 0; i < MAGIC; i++)	p[i][0] = 1;
	par[n++] = -1;

	for (int i = 1; i <= q; i++){
		int type;	cin >> type;
		if (type - 1){
			int v;	cin >> v, v--;
			ld ans = 0;
			for (int h = 1; h < MAGIC; h++)
				ans += (p[h][v] - p[h - 1][v]) * h;
			cout << ans << "\n";
		}
		else{
			int v = n++;
			cin >> par[v], par[v]--;
			for (int h = 0; h < MAGIC; h++)	p[h][v] = 1;

			int tt = v;
			int u = v;
			v = par[v];
			go(v, u);

			v = tt;
			u = v;
			v = par[v];
			for (int j = 0; ~v && j < MAGIC; j++){
				if (j == 0)
					p[0][v] *= 0.5;
				else
					for (int w = 1; w < MAGIC; w++)
						p[w][v] *= (0.5 + 0.5 * p[w - 1][u]);

				u = v;
				v = par[v];
			}
		}
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <memory.h>

using namespace std;

int t[500005], v[500005];
vector<int> g[500005];

const int MAXP = 27;
const int N = MAXP + 2;

double tmp[2][N];

struct SegmentTree {
  SegmentTree(int _n = 0) : n(_n) {
    init(_n);
  }

  void init(int _n) {
    n = _n;
    vector<double> who = vector<double>(2, 0);
    who[0] = 1.0;
    tree = vector<vector<double>>(4 * n + 2, who);
  }

  vector<double> merge(const vector<double> &v1, const vector<double> &v2) {
    memset(tmp, 0, sizeof(tmp));

    tmp[0][0] = v1[0];
    for (int i = 1; i < v1.size(); ++i)
      tmp[0][i] = tmp[0][i - 1] + v1[i];
    tmp[1][0] = v2[0];
    for (int i = 1; i < v2.size(); ++i)
      tmp[1][i] = tmp[1][i - 1] + v2[i];

    vector<double> ret;
    for (int i = 0; i < N; ++i) {
      double cur = tmp[0][i] * tmp[1][i];
      if (i) cur -= tmp[0][i - 1] * tmp[1][i - 1];
      if (cur > 1e-8) ret.push_back(cur);
      else {
        ret.push_back(0);
        break;
      }
    }

    return ret;
  }

  void update(int i, int l, int r, int pos, const vector<double> &v) {
    if (l == r) {
      tree[i] = v;
      return;
    }
    int m = (l + r) >> 1;
    if (pos <= m)
      update(2 * i, l, m, pos, v);
    else
      update(2 * i + 1, m + 1, r, pos, v);

    tree[i] = merge(tree[2 * i], tree[2 * i + 1]);
  }

  void update(int pos, const vector<double> &v) {
    update(1, 0, n - 1, pos, v);
  }

  int n;
  vector<vector<double>> tree;
};

SegmentTree Q[500005];

int par[500005], POS[500005];

int main() {
  // Q[0].init(500000);
  int q;
  scanf("%d", &q);
  int cnt = 1;
  memset(par, -1, sizeof(par));
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &t[i], &v[i]); --v[i];
    if (t[i] == 1) {
      POS[cnt] = g[v[i]].size();
      g[v[i]].push_back(cnt);
      par[cnt] = v[i];
      ++cnt;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    Q[i].init(g[i].size());
  }

  cnt = 1;
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      vector<double> cur(2, 0);
      cur[0] = cur[1] = 0.5;
      int x = cnt, it = 0;
      while (par[x] != -1 && it < MAXP + 5) {
        ++it;
        // cout << x << "  " << par[x] << "  " << POS[x] << endl;
        Q[par[x]].update(POS[x], cur);
        x = par[x];
        cur = Q[x].tree[1];
        vector<double> tmp(1, 0.5);
        for (int i = 0; i < cur.size() && i < N; ++i) {
          if (0.5 * cur[i] > 1e-8) tmp.push_back(0.5 * cur[i]);
          else {
            tmp.push_back(0);
            break;
          }
        }
        cur = tmp;
      }
      ++cnt;
    } else {
      double ans = 0;
      for (int j = 0; j < Q[v[i]].tree[1].size(); ++j) {
        ans += j * Q[v[i]].tree[1][j];
      }
      printf("%.10lf\n", ans);
    }
  }

  // {
  //   int N = 1000, C = 1;
  //   cout << N << endl;
  //   for (int i = 0; i < N; ++i) {
  //     int T = (rand() & 1) + 1;
  //     cout << T << " " << (rand() % C) + 1 << endl;
  //     if (T == 1) ++C;
  //   }
  // }

  return 0;
}

#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
typedef double llf;
#define X first
#define Y second

const int MAX = 1<<19, MAXDUB = 40;
const llf GRAN = 1 - (1e-8);

int vr=1;
int par[MAX];
P q[MAX];
llf umn[MAX][MAXDUB];

void Makni(int ja, int ch)
{
  for (int i=1; i<MAXDUB; i++) {
    if (umn[ch][i-1] > GRAN)
      break;
    umn[ja][i] /= (0.5 * umn[ch][i-1] + 0.5);
  }
}

void Stavi(int ja, int ch)
{
  for (int i=1; i<MAXDUB; i++) {
    if (umn[ch][i-1] > GRAN)
      break;
    umn[ja][i] *= (0.5 * umn[ch][i-1] + 0.5);
  }
}

void Dodaj(int node)
{
  int tmp = node;
  vector <int> V;

  for (int i=0; i<MAXDUB && node; i++, node=par[node])
    V.push_back(node);
  V.push_back(par[node]);

  for (int i=(int) V.size()-1; i>0; i--)
    Makni(V[i], V[i-1]);

  umn[tmp][0] = 0;

  for (int i=0; i<(int) V.size()-1; i++)
    Stavi(V[i+1], V[i]);
}

int main()
{
  int brq;
  int ind = 1;

  scanf("%d", &brq);

  for (int i=0; i<MAX; i++)
    for (int j=0; j<MAXDUB; j++)
      umn[i][j] = 1;

  umn[0][0] = 0;
  for (int i=0; i<brq; i++) {
    scanf("%d%d", &q[i].X, &q[i].Y); q[i].Y--;
    if (q[i].X == 1) {
      par[ind] = q[i].Y;
      Dodaj(ind++);
    }
    else {
      llf ret = 0;
      for (int j=1; j<MAXDUB; j++)
        ret += 1 - umn[q[i].Y][j];

      printf("%.10lf\n", (double) ret);
    }
  }

  return 0;
}

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_map>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int const MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-12;
int INF = INT_MAX / 2;

template <class Monoid>
struct segtree {
	using T = typename Monoid::T;
	int N;
	vector<T> a;
	segtree(const vector<T> &a0) {
		for (N = 1; N < a0.size(); N<<=1);
		a.resize(N<<1);
		copy(a0.begin(), a0.end(), a.begin() + N);
		for (int i = N - 1; i; i--)
			a[i] = Monoid::op(a[i<<1], a[i<<1 | 1]);
	}
	segtree(int N = 0, const T &x = Monoid::id()) :
		segtree(vector<T>(N, x)) {}
	T get(int l, int r) {
		T xl = Monoid::id(), xr = Monoid::id();
		for (l += N, r += N; l < r; l>>=1, r>>=1) {
			if (l & 1) xl = Monoid::op(xl, a[l++]);
			if (r & 1) xr = Monoid::op(a[--r], xr);
		}
		return Monoid::op(xl, xr);
	}
	void set(int i, const T &x) {
		a[i += N] = x;
		while (i>>=1) a[i] = Monoid::op(a[i<<1], a[i<<1 | 1]);
	}
};

struct monoid {
	using T = float;
	static T id() { return 1; }
	static T op(const T &l, const T &r) { return l * r; }
};
typedef segtree<monoid> ST;

int main() {
	int Q; cin >> Q;
	vector<int> t(Q), u(Q);
	rep(k, Q) scanf("%d%d", &t[k], &u[k]), u[k]--;
	int N = 1;
	rep(k, Q) if (t[k] == 1) N++;
	vector<int> par(N); par[0] = -1;
	vector<int> id(N); id[0] = -1;
	vector<vector<int> > G(N);
	int v = 1;
	rep(k, Q) if (t[k] == 1) {
		par[v] = u[k];
		id[v] = G[u[k]].size();
		G[u[k]].pb(v);
		v++;
	}
	vector<int> d(N);
	rep(u, N) d[u] = G[u].size();
	vector<vector<ST> > st(N, vector<ST>(30));
	rep(u, N) rep(h, 30) st[u][h] = ST(d[u]);
	int v0 = 1;
	rep(k, Q) {
		if (t[k] == 1) {
			int v = v0;
			rep(h, 30) {
				int p = par[v], i = id[v];
				if (p == -1) break;
				if (!h) st[p][0].set(i, 0.5);
				else st[p][h].set(i, 0.5 + 0.5 * st[v][h - 1].get(0, d[v]));
				v = p;
			}
			v0++;
		}
		if (t[k] == 2) {
			int v = u[k];
			double ans = 0;
			rep(h, 29) {
				double p = st[v][h + 1].get(0, d[v]) - st[v][h].get(0, d[v]);
				ans += p * (h + 1);
			}
			printf("%.10f\n", ans);
		}
	}
}

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 5e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

const int Bound = 22;

struct SegmentTree {
  vector < int > active;
  vector < vector < double > > t;
  int size;
  void build(vector < int > &_childs) {
    size = (int)_childs.size();
    active.resize(4 * size);
    t.resize(4 * size);
    for (int i = 0; i < (int)t.size(); ++i) {
      t[i] = vector < double >(min(size, Bound), 0);
    }
  }
  int fmax(int i, int j) {
    return i > j ? i : j;
  }
  void combine(vector < double > &res, const vector < double > &a, const vector < double > &b) {
    for (int i = 0; i < min(size, Bound); ++i) {
      res[i] = 0;
    }
    for (int i = 0; i < min(size, Bound); ++i) {
      for (int j = 0; j < min(size, Bound); ++j) {
        res[fmax(i, j)] += a[i] * b[j];
      }
    }
  }
  void update(int v, int l, int r, int pos, const vector < double > &val) {
    active[v] = 1;
    if (l == r) {
      for (int i = 1; i < min(size, Bound) && i < (int)val.size(); ++i) {
        t[v][i] = val[i - 1] / 2.0;
      }
      t[v][0] = 0.5;
      return;
    }
    int m = (l + r) / 2;
    if (pos <= m) {
      update(v + v, l, m, pos, val);
    } else {
      update(v + v + 1, m + 1, r, pos, val);
    }
    if (active[v + v] && active[v + v + 1]) {
      combine(t[v], t[v + v], t[v + v + 1]);
    } else if (active[v + v]) {
      t[v] = t[v + v];
    } else {
      t[v] = t[v + v + 1];
    }
  }
} seg[MaxN];

int q, pred[MaxN];
vector < int > graph[MaxN];

void dfs(int v) {
  if (graph[v].empty()) {
    return;
  }
  seg[v].build(graph[v]);
  for (int i = 0; i < (int)graph[v].size(); ++i) {
    int to = graph[v][i];
    dfs(to);
  }
}

int fnd(int v, int ind) {
  return lower_bound(graph[v].begin(), graph[v].end(), ind) - graph[v].begin();
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d", &q);
  vector < pair < int, int > > changes;
  for (int i = 0, s = 1; i < q; ++i) {
    int type, v;
    scanf("%d%d", &type, &v);
    changes.push_back(make_pair(type, v));
    if (type == 1) {
      ++s;
      graph[v].push_back(s);
      pred[s] = v;
    }
  }
  dfs(1);
  for (int it = 0, s = 1; it < q; ++it) {
    if (changes[it].first == +1) {
      int where = ++s;
      vector < double > f(Bound);
      f[0] = 1.0;
      for (int v = pred[where], dep = Bound; v != 0 && dep > 0; where = v, v = pred[v], --dep) {
        int pos = fnd(v, where);
        seg[v].update(1, 0, seg[v].size - 1, pos, f);
        f = seg[v].t[1];
      }
    } else {
      int where = changes[it].second;
      double ans = 0;
      if (!graph[where].empty()) {
        vector < double > f = seg[where].t[1];
        for (int i = 0; i < (int)f.size(); ++i) {
          ans += f[i] * i;
        }
      }
      printf("%.9lf\n", ans);
    }
  }
  return 0;
}

#include <bits/stdc++.h> // PLEASE

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 500005
#define MAXM 60
#define MAXP 22
#define INF 2000100000
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll MOD = 1e9+7;
int Q;
int N = 1;
double dp[MAXN][MAXM];
int par[MAXN];

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> Q;
	dp[1][0] = 1.0;
	for(int i=0; i<Q; i++) {
		int t, x;
		cin >> t >> x;
		if(t == 1) {
			par[++N] = x;
			dp[N][0] = 1.0;
			int cur = x;
			int ch = N;
			double v = 0;
			for(int j=1; cur != 0 && j<MAXM; j++) {
				double mul = 1.0 - dp[cur][j];
				mul /= (0.5 + 0.5 * (1-v));
				mul *= (0.5 + 0.5 * (1-dp[ch][j-1]));
				v = dp[cur][j];
				dp[cur][j] = 1.0-mul;
				ch = cur;
				cur = par[cur];
			}
		}
		else {
			double ret = 0;
			for(int i=1; i<MAXM; i++) ret += dp[x][i];
			cout << ret << endl;
		}
	}
}

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <utility>
#include <vector>

const int M = 30;

int main()
{
    int q;
    scanf("%d", &q);
    std::vector<int> parent;
    std::vector<std::vector<double>> prob;
    parent.push_back(-1);
    std::vector<double> empty(M);
    for (int i = 1; i < M; ++ i) {
        empty[i] = 1.;
    }
    prob.push_back(empty);
    while (q --) {
        int t, v;
        scanf("%d%d", &t, &v);
        v --;
        if (t == 1) {
            int p = parent.size();
            parent.push_back(v);
            prob.push_back(empty);
            std::vector<int> ancestors;
            for (int _ = 0; _ < M && ~p; ++ _) {
                ancestors.push_back(p);
                p = parent[p];
            }
            for (int i = (int)ancestors.size() - 1; i >= 2; -- i) {
                int p = ancestors[i];
                int q = ancestors[i - 1];
                for (int j = 1; j < M; ++ j) {
                    prob[p][j] /= .5 * (1. + prob[q][j - 1]);
                }
            }
            for (int i = 1; i < (int)ancestors.size(); ++ i) {
                int p = ancestors[i];
                int q = ancestors[i - 1];
                for (int j = 1; j < M; ++ j) {
                    prob[p][j] *= .5 * (1. + prob[q][j - 1]);
                }
            }
        } else {
            double result = 0.;
            for (int i = 1; i < M; ++ i) {
                result += (1. - prob[v][i]);
            }
            printf("%.9f\n", result);
        }
    }
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=58;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}

			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				ps[i][0] = sum[now][0];
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					ps[i][j] = sum[now][j];
					if(ps[i-1][j-1]>1e-25)
						sum[now][j]/=(0.5+ps[i-1][j-1]/2);
					sum[now][j]*=(0.5+sum[prev][j-1]/2);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			ans+=(M+1)*(1-sum[v][M]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include<cstdio>
#include<algorithm>
#ifndef GZOTPA
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif
#define N 500010
#define K 3
using namespace std;
int q,fa[N],n=1;
double f[N][K+5],pre[N];
int main()
{
	scanf("%d",&q);
	f[n][0]=1;
	int x,t,y;
	while(q--)
	{
		scanf("%d%d",&t,&x);
		if(t==1)
		{
			f[++n][0]=1;
			fa[n]=x;
			y=n;
			for(int i=1;x&&i<=K;i++,x=fa[x],y=fa[y])
			{
				debug("%.3lf %.3lf\n",pre[y],f[y][i-1]);
				pre[x]=f[x][i];
				f[x][i]=1.-(1.-f[x][i])*(.5+.5*(1.-f[y][i-1]))/(.5+.5*(1.-pre[y]));
			}
			debug("haha\n");
			for(int i=1;i<=n;i++)
			{
				for(int j=0;j<=K;j++)
				debug("%.3lf ",f[i][j]);
				debug("\n");
			}
		}
		else
		{
			double ans=0;
			for(int i=1;i<=K;i++)
			ans+=(f[x][i]-f[x][i+1])*i;
			printf("%.8lf\n",ans);
		}
	}
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define mp(a,b) make_pair(a,b)
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef long double db;
typedef pair<int ,int> p1;
const int maxn=500005;
int root;
int fa[maxn];
db dp[maxn][41];
db s;
void update(int u,int pre,int d){
	if(d>40) return ;
	db s1=2;
	if(u!=pre){
		s1=dp[u][d-1];
		if(d>1){
			s1=s1/(0.5+0.5*dp[pre][d-2]);
		}
	}
	s=s*0.5*s1;
	s1=s;
	if(fa[u]!=u) update(fa[u],u,d+1);
	if(d==0){
		for(int i=0;i<=40;i++) dp[u][i]=1;
	}
	else{
		dp[u][d-1]-=s1;
	}
}
int main()
{
	int m;
	cin>>m;
	fa[1]=1;
	for(int i=0;i<=30;i++) dp[1][i]=1;
	int cnt=2;
	for(int i=0;i<m;i++){
		int p;
		s=1;
		scanf("%d",&p);
		if(p==1){
			int v;
			scanf("%d",&v);
			fa[cnt]=v;
			update(cnt,cnt,0);
			cnt++;
		}
		else{
			int u;
			scanf("%d",&u);
			db s=0;
			for(int i=1;i<=40;i++){
				s+=(dp[u][i]-dp[u][i-1])*i;
			}
			double  s1=s;
			printf("%.10lf\n",s1);
		}
	}
}

#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<vector<ll> > mat;

const int N = 5e5 + 10;
const ll INF = 1e17 + 1;
const ll MOD = 1e9 + 7;
const int M = 1e6 + 10;
const int H = 41;
const ld EPS = 1e-12;

ld pref[N][H + 1];
int par[N];
vector<int> g[N];
ld pows[H + 1];
ld mults[N][H + 1];

void recalc(int v, int height, int last) {
    assert(v >= 0 && v < N);
    assert(height >= 0 && height <= H);
    if (!height) {
        fill(pref[v], pref[v] + H + 1, 1);
        fill(mults[v], mults[v] + H + 1, 1);
    }
    if (g[v].size()) {
        int u = last;
        if (height == 1) {
            if (par[v] != -1 && abs((1 + pref[v][0]) / 2) > EPS)
                mults[par[v]][0] /= ((1 + pref[v][0]) / 2);
            pref[v][0] = pows[g[v].size()];
            if (par[v] != -1)
                mults[par[v]][0] *= ((1 + pref[v][0]) / 2);
        }
        else {
            for (int h = height - 1; h <= height - 1; h++) {
                if (par[v] != -1 && abs((1 + pref[v][0]) / 2) > EPS)
                    mults[par[v]][h] /= ((1 + pref[v][h]) / 2);
                ld tmp = (mults[v][h - 1] -
                    (h - 1 > 0 ? mults[v][h - 2] : pows[g[v].size()]));
                pref[v][h] = tmp + (h - 1 >= 0 ? pref[v][h - 1] : 0);
                assert(pref[v][h] > -EPS && pref[v][h] < 1 + EPS);
                assert(!isnan(pref[v][h]));
                if (par[v] != -1)
                    mults[par[v]][h] *= ((1 + pref[v][h]) / 2);
            }
        }
    }
}

void solve() {
    int q;
    cin >> q;
    fill(par, par + q + 1, -1);
    pows[0] = 1;
    for (int i = 1; i <= H; i++)
        pows[i] = pows[i - 1] / 2.0;

    recalc(0, 0, -1);

    int curInd = 1;
    for (int i = 0; i < q; i++) {
        int typ, v;
        cin >> typ >> v;
        v--;
        if (typ == 1) {
            par[curInd] = v;
            g[v].pb(curInd);

            int u = curInd;
            int lastu = -1;
            for (int i = 0; i < H; i++) {
                recalc(u, i, lastu);
                lastu = u;
                if (par[u] != -1) {
                    u = par[u];
                } else {
                    break;
                }
            }
            curInd++;
        } else {
            ld ans = 0;
            for (int i = 0; i <= H; i++) {
                ans += i * (pref[v][i] - (i ? pref[v][i - 1] : 0));
            }
            cout << fixed << setprecision(12) << ans << "\n";
        }

    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("a.in", "r", stdin);
    int tst = 1;
    while (tst--)
        solve();
}

#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
double dp[500100][42];
int num_q,v,flag,pa[501000],n,list[33],cnt_list,pw[501000];
int main()
{
	int i,j,s,p,q,id,ip;
	scanf("%d",&num_q);
	n=1;
	for(i=0;i<=40;i++)
	   dp[0][i]=1.;
	for(i=0;i<=500000;i++)
	{
		if(i==0)
		  pw[i]=1;
        else
          pw[i]=0.5*pw[i-1];
	}
	while(num_q--)
	{
		scanf("%d%d",&flag,&v);
		v--;
		if(flag==1)
		{
			pa[n++]=v;
			id=n-1;
		    cnt_list=0;
		    while(id!=0&&cnt_list<=40)
		    {
			    list[cnt_list++]=id;
			    id=pa[id];
    		}
    		if(cnt_list<=40)
    		  list[cnt_list++]=0;
    		for(i=cnt_list-1;i>0;i--)
    		{
		    	id=list[i];
		    	ip=list[i-1];
				for(j=1;j<i;j++)
				   dp[id][j]/=(dp[ip][j-1]*0.5+0.5);
			}
   			for(i=0;i<=40;i++)
			   dp[n-1][i]=1.;
			dp[v][0]*=0.5;
			for(i=1;i<cnt_list;i++)
		    {
    			id=list[i];
    			ip=list[i-1];
    			for(j=1;j<i;j++)
			    	dp[id][j]*=(dp[ip][j-1]*0.5+0.5);
		    //	if(i==2)
		    //	   printf("dp[%d][1]=%.20f\n",id,dp[id][1]);
		    //	if(i==2)
		    	//   printf("dp[%d][2]=%.20f\n",id,dp[id][i]);
    		}
		}
		else
		{
		    double ans=0;
		    for(i=1;i<=40;i++)
		    {
		       ans+=i*(dp[v][i]-dp[v][i-1]);
		    //   if(i==1)
		         // printf("orz=%.20f\n",dp[v][i]-dp[v][i-1]);
			}
			printf("%.20f\n",ans);
		}
	}
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define mp(a,b) make_pair(a,b)
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef long double db;
typedef pair<int ,int> p1;
const int maxn=500005;
int root;
int fa[maxn];
db dp[maxn][32];
db s;
void update(int u,int pre,int d){
	if(d>30) return ;
	db s1=2;
	if(u!=pre){
		s1=dp[u][d-1];
		if(d>1){
			s1=s1/(0.5+0.5*dp[pre][d-2]);
		}
	}
	s=s*0.5*s1;
	s1=s;
	if(fa[u]!=u) update(fa[u],u,d+1);
	if(d==0){
		for(int i=0;i<=30;i++) dp[u][i]=1;
	}
	else{
		dp[u][d-1]-=s1;
	}
}
int main()
{
	int m;
	cin>>m;
	fa[1]=1;
	for(int i=0;i<=30;i++) dp[1][i]=1;
	int cnt=2;
	for(int i=0;i<m;i++){
		int p;
		s=1;
		scanf("%d",&p);
		if(p==1){
			int v;
			scanf("%d",&v);
			fa[cnt]=v;
			update(cnt,cnt,0);
			cnt++;
		}
		else{
			int u;
			scanf("%d",&u);
			db s=0;
			for(int i=1;i<=30;i++){
				s+=(dp[u][i]-dp[u][i-1])*i;
			}
			double  s1=s;
			printf("%.10lf\n",s1);
		}
	}
}

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 5e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

const int Bound = 35;

double ta[Bound], tb[Bound];

struct SegmentTree {
  vector < int > active;
  vector < vector < double > > t;
  int size;
  void build(vector < int > &_childs) {
    size = (int)_childs.size();
    active.resize(2 * size);
    t.resize(2 * size);
    for (int i = 0; i < (int)t.size(); ++i) {
      t[i] = vector < double >(Bound, 0);
    }
  }
  int fmax(int i, int j) {
    return i > j ? i : j;
  }
  void combine(vector < double > &res, const vector < double > &a, const vector < double > &b) {
    for (int i = 0; i < Bound; ++i) {
      ta[i] = a[i] + (i > 0 ? ta[i - 1] : 0);
      tb[i] = b[i] + (i > 0 ? tb[i - 1] : 0);
    }
    for (int j = 0; j < Bound; ++j) {
      res[j] = ta[j] * b[j] + tb[j] * a[j] - a[j] * b[j];
    }
  }
  void update(int v, const vector < double > &val) {
    v += size;
    active[v] = 1;
    for (int i = 1; i < Bound; ++i) {
      t[v][i] = val[i - 1] / 2.0;
    }
    t[v][0] = 0.5;
    for (v >>= 1; v > 0; v >>= 1) {
      if (active[v + v] && active[v + v + 1]) {
        combine(t[v], t[v + v], t[v + v + 1]);
      } else if (active[v + v]) {
        t[v] = t[v + v];
      } else {
        t[v] = t[v + v + 1];
      }
      active[v] = 1;
    }
  }
} seg[MaxN];

int q, pred[MaxN];
vector < int > graph[MaxN];

void dfs(int v) {
  if (graph[v].empty()) {
    return;
  }
  seg[v].build(graph[v]);
  for (int i = 0; i < (int)graph[v].size(); ++i) {
    int to = graph[v][i];
    dfs(to);
  }
}

int fnd(int v, int ind) {
  return lower_bound(graph[v].begin(), graph[v].end(), ind) - graph[v].begin();
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d", &q);
  vector < pair < int, int > > changes;
  for (int i = 0, s = 1; i < q; ++i) {
    int type, v;
    scanf("%d%d", &type, &v);
    changes.push_back(make_pair(type, v));
    if (type == 1) {
      ++s;
      graph[v].push_back(s);
      pred[s] = v;
    }
  }
  dfs(1);
  for (int it = 0, s = 1; it < q; ++it) {
    if (changes[it].first == +1) {
      int where = ++s;
      vector < double > f(Bound);
      f[0] = 1.0;
      for (int v = pred[where], dep = Bound; v != 0 && dep > 0; where = v, v = pred[v], --dep) {
        int pos = fnd(v, where);
        seg[v].update(pos, f);
        f = seg[v].t[1];
      }
    } else {
      int where = changes[it].second;
      double ans = 0;
      if (!graph[where].empty()) {
        vector < double > f = seg[where].t[1];
        for (int i = 0; i < (int)f.size(); ++i) {
          ans += f[i] * i;
        }
      }
      printf("%.9lf\n", ans);
    }
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define double long double
const int maxn=5e5+10;
const int Lim=60;
int n,tot_Node;
int prt[maxn];
double f[maxn][63];
inline int Read(){
	register int ch,a;
	while(ch=getchar(),ch<'0'&&ch>'9');a=(ch^48);
	while(ch=getchar(),ch>='0'&&ch<='9')a=a*10+(ch^48);
	return a;
}
double Last[63];
inline void Update(int u){
//	printf("Update %d->%d\n",u,prt[u]);
	Last[0]=1;
	for(int d=1;d<=Lim;d++)f[u][d]=Last[d]=1;
	for(int c=2;prt[u]&&c<=Lim;c++,u=prt[u]){
//		printf("f[%d][0]=%Lf\n",u,f[u][0]);
		for(int d=Lim;d>=1;d--){
			Last[d]=f[prt[u]][d];
			f[prt[u]][d]/=(Last[d-1]+1)/2;
			f[prt[u]][d]*=(f[u][d-1]+1)/2;
		}
		Last[0]=0;
	}
//	for(int i=1;i<=tot_Node;i++){
//		printf("f %d:\n",i);
//		for(int d=1;d<=3;d++)printf("p[%d]=%Lf\n",d,f[u][d]);
//	}
}
inline double Query(int u){
	double ret=-1;
	for(int d=1;d<=Lim;d++)ret+=(f[u][d]-f[u][d-1])*d;
	return ret;
}
int main(){
//	freopen("in.in","r",stdin);
//	freopen("mine.out","w",stdout);
	n=Read();
	tot_Node=1;
	for(int i=1;i<=Lim;i++)f[1][i]=1;
	int tp,u;
	while(n--){
		tp=Read(),u=Read();
		if(tp==1)prt[++tot_Node]=u,Update(tot_Node);
		else printf("%.8Lf\n",Query(u));
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cassert>
#include <map>
#include <string>
#include <iomanip>
#include <set>
#include <queue>
#include <ctime>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define sz(v) (int)(v).size()
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef double LD;
//typedef long long LL;

const LD eps = 1e-10;
const int N = 500007;
const int K = 32;

LD dp[K][N], tmp[K], old_dp[K];
int next_node=2, par[N];
bool random = false;

void get(int &ty, int &u) {
    if (random) {
        ty = rand() % 2 + 1;
        //u = next_node - 2- rand() % 1;
        u = rand() % (next_node-1)+1;
        if (u < 0) u = 1;
    }
    else {
        scanf("%d%d", &ty, &u);
    }
}

void solve() {
    srand(time(0));
    FOR(h, K) dp[h][1] = 1.0;
    int q;
    scanf("%d", &q);
    while(q--) {
        int ty, u;
        get(ty, u);
        if (ty == 1) {
            int new_node = next_node++;
            par[new_node] = u;
            FOR(h, K) dp[h][new_node] = 1.0;
            int son = new_node;
            FOR(iter, K) {
                if (u == 0) break;

                FOR(h, K) tmp[h] = dp[h][u];

                FOR(h, K) {
                    if (son == new_node) {
                        dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0));
                    }
                    else {
                        dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0))/(0.5 + 0.5 * (h ? old_dp[h-1]:0.0));
                    }
                }

                FOR(h, K) old_dp[h] = tmp[h];
                son = u;
                u = par[u];
            }
        }
        if (ty == 2) {
            LD ans = 0;
            FOR(h, K) {
                LD pr = (dp[h][u] - (h ? dp[h-1][u] : 0.0));
                ans += pr * h;
            }
            printf("%.9f\n", (double)ans);
        }
    }
}

void testgen() {
    FILE *f = fopen("input.txt", "w");
    srand(time(0));
    fclose(f);
}

int  main(int argc, char* argv[]) {
#ifdef harhro94
    //testgen();
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    #define task "estimate"
    //freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif

    solve();

#ifdef harhro94
    cerr << "\ntime = " << clock() / 1000.0 << endl;
#endif
    return 0;
}

//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2147483647;
#define LL long long

inline int read();

const int N=5e5+2;
const int H=34;
int n, c;
double pre, now;
int f[N];
double dp[N][H+2];

void Insert(int x)
{
    f[++c]=x;
    for(int i=0; i<=H; ++i) dp[c][i]=1;
    if(x) pre=dp[x][0], dp[x][0]*=0.5;
    for(int i=1, y=x; i<=H; ++i)
    {
        int p=f[y]; if(!p) break;
        now=dp[p][i];
        dp[p][i]=dp[p][i]/(0.5+0.5*pre)*(0.5+0.5*dp[y][i-1]);
        pre=now; y=f[y];
    }
}

void Query(int x)
{
    double ans=0;
    for(int i=1; i<=H; ++i) ans+=(dp[x][i]-dp[x][i-1])*i;
    printf("%.10lf\n", ans);
}

void Work()
{
    n=read(); Insert(0);
    for(int i=1; i<=n; ++i)
        if(read()==1) Insert(read());
        else Query(read());
}

int main()
{
    #ifdef gc
    freopen("643e.in","r",stdin);
    freopen("643e.out","w",stdout);
    #endif

    Work();

    return 0;
}

inline int read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    int ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ri register int
#define il inline
typedef long long LL;
template<class T>il void in(T &x)
{
	x=0; char c=getchar(); bool f=0;
	while(!isdigit(c)) f|=(c=='0'),c=getchar();
	while(isdigit(c)) x=x*10+(c^'0'),c=getchar();
	f?x=-x:0;
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[40]; short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(c);
}
template<class T>il void err(const T &x,const char c='\n') {cerr<<x<<c;}
template<class T,class ...Args>il void err(const T &x,const Args &...args) {err(x,' '),err(args...);}
namespace i207M
{
const int N=500005;
int cq;
int fa[N],tot;
double f[N][22];
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
#endif
	in(cq);
	++tot;
	for(ri i=1;i<=21;++i) f[1][i]=1;
	int op;
	for(ri i=1,x;i<=cq;++i)
	{
		in(op);
		if(op==1)
		{
			in(fa[x=++tot]);
			for(ri i=1;i<=21;++i) f[x][i]=1;
			static int st[N]; int tp=0;
			for(ri i=1;i<=21&&x;++i,x=fa[x]) st[++tp]=x;
			for(ri i=tp;i>=3;--i)
			{
				for(ri j=1;j<=21;++j)
					f[st[i]][j]/=f[st[i-1]][j-1]*0.5+0.5;
			}
			for(ri i=2;i<=tp;++i)
				for(ri j=1;j<=21;++j)
					f[st[i]][j]*=f[st[i-1]][j-1]*0.5+0.5;
		}
		else
		{
			in(op);
			double ans=0;
			for(ri i=1;i<=21;++i) ans+=1-f[op][i];
			printf("%.10f\n",ans);
		}
	}
	return 0;
}
}
signed main()
{
	i207M::main();
	return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) w = ch == '-' ? -1 : 1, ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
const int Max_n = 5e5 + 5;
long double f[Max_n][51];
int n;
int top, stk[Max_n];
int cnt, fa[Max_n];
void node_init() {
  for (int i = 0; i <= 50; i++) f[cnt][i] = 1;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("E.in", "r", stdin);
  freopen("E.out", "w", stdout);
#endif
  n = read();
  cnt = 1;
  node_init();
  while (n--) {
    if (read() == 1) {
      fa[++cnt] = read(), node_init();
      stk[top = 0] = fa[cnt];
      for (int x = fa[cnt]; fa[x] && top <= 50; x = fa[x]) stk[++top] = fa[x];
      for (int i = top; i; i--) f[stk[i]][i] /= (f[stk[i - 1]][i - 1] + 1);
      f[fa[cnt]][0] *= 0.5;
      for (int x = fa[cnt], to = 1; fa[x] && to <= 50; to++, x = fa[x]) {
        f[fa[x]][to] *= (f[x][to - 1] + 1);
      }
    } else {
      long double ans = 0;
      int x = read();
      for (int i = 1; i <= 50; i++) ans += (double)i * (f[x][i] - f[x][i - 1]);
      printf("%.6Lf\n", ans);
    }
  }
}

#include<cstdio>
#include<algorithm>
#include<vector>
//#define int long long
using namespace std;
const int MAXN = 5 * 1e5 + 10, MaxH = 60;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int T, Q, fa[MAXN], N;
vector<int> v[MAXN];
double f[MAXN][61];
void mem(double *f) {
	for(int i = 0; i <= MaxH; i++) f[i] = 1;
}
main() {
	T = read(); Q = read(); N = 1;
	mem(f[1]);
	while(Q--) {
		int opt = read(), x = read();
		if(opt == 1) {
			fa[++N] = x;
			mem(f[N]);
			double pre = f[x][0], now;
			f[x][0] *= 0.5;
			for(int h = 1; h <= MaxH; h++, x = fa[x]) {
				now = f[fa[x]][h];
				f[fa[x]][h] /= 0.5 + 0.5 * pre;
				f[fa[x]][h] *= 0.5 + 0.5 * f[x][h - 1];
				pre = now;
			}
		} else if(opt == 2) {
			double ans = 0;
			for(int i = 0; i <= MaxH; i++) ans += i * (f[x][i] - f[x][i - 1]);
			printf("%.10lf\n", ans);
		}
	}
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define mp(a,b) make_pair(a,b)
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef long double db;
typedef pair<int ,int> p1;
const int maxn=500005;
int root;
int fa[maxn];
db dp[maxn][41];
db s;
void update(int u,int pre,int d){
	if(d>40) return ;
	db s1=2;
	if(u!=pre){
		s1=dp[u][d-1];
		if(d>1){
			s1=s1/(0.5+0.5*dp[pre][d-2]);
		}
	}
	s=s*0.5*s1;
	s1=s;
	if(fa[u]!=u) update(fa[u],u,d+1);
	if(d==0){
		for(int i=0;i<=30;i++) dp[u][i]=1;
	}
	else{
		dp[u][d-1]-=s1;
	}
}
int main()
{
	int m;
	cin>>m;
	fa[1]=1;
	for(int i=0;i<=30;i++) dp[1][i]=1;
	int cnt=2;
	for(int i=0;i<m;i++){
		int p;
		s=1;
		scanf("%d",&p);
		if(p==1){
			int v;
			scanf("%d",&v);
			fa[cnt]=v;
			update(cnt,cnt,0);
			cnt++;
		}
		else{
			int u;
			scanf("%d",&u);
			db s=0;
			for(int i=1;i<=40;i++){
				s+=(dp[u][i]-dp[u][i-1])*i;
			}
			double  s1=s;
			printf("%.10lf\n",s1);
		}
	}
}

#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = l; i < r; i++)
#define FST first
#define SCD second
#define modp  1000000007
#define MAXN 500113
#define MAXL 61
#define EPS 1e-7
using namespace std;

typedef long long LL;
typedef unsigned int UI;

int Q;
double dp[MAXN][MAXL];
int ml[MAXN];
int f[MAXN];
void update(int v, double pre, double cur, int l)
{
    if (l == MAXL || v == 0) {
        return;
    }
    if (l >= ml[v]) {
        ml[v]++;
        dp[v][l] = 1;
    }
    double tmp = dp[v][l];
    dp[v][l] *= (1 + cur) / (1 + pre);
    update(f[v], tmp, dp[v][l], l + 1);
}

int main()
{
    scanf("%d", &Q);
    int k = 1;
    dp[0][0] = 1;
    FOR(i, 0, Q) {
        int t, v;
        scanf("%d%d", &t, &v);
        if (t == 1) {
            f[++k] = v;
            dp[k][0] = 1;
            update(v, 1, 0, 0);
        }
        else {
            double S = 0;
            FOR(i, 0, MAXL) {
                if (i >= ml[v]) {
                    dp[v][ml[v]++] = 1;
                }
                if (dp[v][i] > 1 - EPS) {
                    S += i * dp[v][i];
                    break;
                }
                S -= dp[v][i];
            }
            printf("%.12f\n", S);
        }
    }
    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iostream>
#include <set>
#include <fstream>
#include <string>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
#define FOR(i,s,e) for (int i=(s); i<(e); i++)
#define FOE(i,s,e) for (int i=(s); i<=(e); i++)
#define FOD(i,s,e) for (int i=(s); i>=(e); i--)
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define LL long long
#define ULL unsigned long long
#define eps 1e-9
#define pi acos(-1.0)
LL max(LL a,LL b){if (a>b){return a;} else {return b;}}
LL min(LL a,LL b){if (a<b){return a;} else {return b;}}

#define K 600001

int cnt[K], q1[K], q2[K], h, rb[K], par[K], lb[K], he[K], rt[K], n;
double dp[K][24], sum[K][24], nw[K][24];

int co, q;

double f(int a, int b, int op){
	if (op == 2) return nw[a][b]; else return sum[a][b];
	double ret = (op==2?nw[a][b]:sum[a][b]);
	if (b != 0) ret -= (op==2?nw[a][b]:sum[a][b - 1]);
	return ret;
}

void recalc(int u, int w, int lv, int nc){
	//printf("recalc %d %d %d %d\n", u, w, lv, nc);
	if (u == 0 || lv >= 24) return;
	FOE(j, 0, 23){
		nw[u][j] = sum[u][j];
		if (nc) nw[u][j] /= (double)2.00;
		if (j != 0){
	//		if (j <= n) printf("rebuild %d, layer %d: cof is %.9f / (1/2*(1+%.9f)) * (1/2*(1+%.9f))\n",
	//					u, j, sum[u][j], f(w, j - 1, 1), f(w, j - 1, 2));
			nw[u][j] = sum[u][j] / (1.00 / 2 * (1.00 + f(w, j - 1, 1)))
				* (1.00 / 2 * (1.00 + f(w, j - 1, 2)));
		}
	}
	recalc(par[u], u, lv + 1, 0);
	FOE(j, 0, 23) sum[u][j] = nw[u][j];
}

int main(){
	scanf("%d", &q);
	n = 1;
	FOE(i, 0, 23) sum[1][i] = 1.000;
	FOE(i, 1, q){
		scanf("%d%d", &q1[i], &q2[i]);
		if (q1[i] == 1) {
			n++; par[n] = q2[i];
			FOE(j, 0, 23) nw[n][j] = sum[n][j] = 1.00;
			recalc(q2[i], n, 1, 1);
		} else {
			double ret = 0.00;
			FOE(j, 1, 23) {
	//			if (j <= n) printf("diff is %.9f - %.9f\n",
	//					sum[q2[i]][j], sum[q2[i]][j - 1]);
				ret = (ret + (double)j * (sum[q2[i]][j] - sum[q2[i]][j - 1]));
			}
			printf("%.12f\n", ret);
		}
	}

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-12
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define __builtin_popcount __builtin_popcountll
typedef vector<int> VI;
typedef  long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a , a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
double power(double a, ll n)
{double p = 1.0;while (n > 0) {if(n%2) {p = p * a; } n >>= 1; a *= a;} return p;}
inline bool input(int &num)
{
        char in;bool IsN=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&(in<'0'||in>'9')) in=getchar();
        if(in=='-'){ IsN=true;num=0;}
        else num=in-'0';
        while(in=getchar(),in>='0'&&in<='9'){
                num*=10,num+=in-'0';
        }
        if(IsN) num=-num;
        return true;
}
int inf = 0x3f3f3f3f,t1=277,t2=233,mod = 1e9 + 7;
const int maxn = 5e5 + 100;
const double PI = acos(-1.0);

int n,m;
double dp[maxn][70];
int fa[maxn];
int main(){
    int T,s,e;
    while(cin>>n){
        int cur=1;
        for(int i=1;i<=n;i++)
            for(int j=0;j<=30;j++)
            dp[i][j]=1;
        memset(fa,0,sizeof fa);
        for(int i=1;i<=n;i++)
        {
            int t,x;scanf("%d%d",&t,&x);
            if(t==1)
            {
                cur++;
                fa[cur]=x;
                int cun=0;
                double be=1.0;
                for(int j=cur;j!=1;j=fa[j])
                {
                    double gg=dp[fa[j]][cun];
                    dp[fa[j]][cun]/=(be+1.0);
                    be=gg;
                    if(cun!=0)
                    dp[fa[j]][cun]*=(dp[j][cun-1]+1.0);
                    cun++;
                    if(cun>30)break;
                }
            }
            else
            {
                double ans=0;
                for(int i=1;i<=30;i++)
                {

                    ans+=(dp[x][i]-dp[x][i-1])*(double)i;
                }
                printf("%.10f\n",ans);
            }
        }

    }
    return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=50;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}
			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				for(int j=0; j<=i; j++) ps[i][j] = sum[now][j];
				prev = now;
				now = parent[now];
			}

			prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					if(ps[i-1][j-1]!=0)
					sum[now][j]/=(0.5+0.5*ps[i-1][j-1]);
					sum[now][j]*=(0.5+0.5*sum[prev][j-1]);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <memory.h>

using namespace std;

int t[500005], v[500005];
vector<int> g[500005];

const int MAXP = 28;
const int N = MAXP + 2;

double tmp[2][N];

struct SegmentTree {
  SegmentTree(int _n = 0) : n(_n) {
    init(_n);
  }

  void init(int _n) {
    n = _n;
    vector<double> who = vector<double>(2, 0);
    who[0] = 1.0;
    tree = vector<vector<double>>(4 * n + 2, who);
  }

  vector<double> merge(const vector<double> &v1, const vector<double> &v2) {
    memset(tmp, 0, sizeof(tmp));

    tmp[0][0] = v1[0];
    for (int i = 1; i < v1.size(); ++i)
      tmp[0][i] = tmp[0][i - 1] + v1[i];
    tmp[1][0] = v2[0];
    for (int i = 1; i < v2.size(); ++i)
      tmp[1][i] = tmp[1][i - 1] + v2[i];

    vector<double> ret;
    for (int i = 0; i < N; ++i) {
      double cur = tmp[0][i] * tmp[1][i];
      if (i) cur -= tmp[0][i - 1] * tmp[1][i - 1];
      if (cur > 1e-9) ret.push_back(cur);
      else {
        ret.push_back(0);
        break;
      }
    }

    return ret;
  }

  void update(int i, int l, int r, int pos, const vector<double> &v) {
    if (l == r) {
      tree[i] = v;
      return;
    }
    int m = (l + r) >> 1;
    if (pos <= m)
      update(2 * i, l, m, pos, v);
    else
      update(2 * i + 1, m + 1, r, pos, v);

    tree[i] = merge(tree[2 * i], tree[2 * i + 1]);
  }

  void update(int pos, const vector<double> &v) {
    update(1, 0, n - 1, pos, v);
  }

  int n;
  vector<vector<double>> tree;
};

SegmentTree Q[500005];

int par[500005], POS[500005];

int main() {
  // Q[0].init(500000);
  int q;
  scanf("%d", &q);
  int cnt = 1;
  memset(par, -1, sizeof(par));
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &t[i], &v[i]); --v[i];
    if (t[i] == 1) {
      POS[cnt] = g[v[i]].size();
      g[v[i]].push_back(cnt);
      par[cnt] = v[i];
      ++cnt;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    Q[i].init(g[i].size());
  }

  cnt = 1;
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      vector<double> cur(2, 0);
      cur[0] = cur[1] = 0.5;
      int x = cnt, it = 0;
      while (par[x] != -1 && it < MAXP + 5) {
        ++it;
        // cout << x << "  " << par[x] << "  " << POS[x] << endl;
        Q[par[x]].update(POS[x], cur);
        x = par[x];
        cur = Q[x].tree[1];
        vector<double> tmp(1, 0.5);
        for (int i = 0; i < cur.size() && i < N; ++i) {
          if (0.5 * cur[i] > 1e-9) tmp.push_back(0.5 * cur[i]);
          else {
            tmp.push_back(0);
            break;
          }
        }
        cur = tmp;
      }
      ++cnt;
    } else {
      double ans = 0;
      for (int j = 0; j < Q[v[i]].tree[1].size(); ++j) {
        ans += j * Q[v[i]].tree[1][j];
      }
      printf("%.10lf\n", ans);
    }
  }

  // {
  //   int N = 1000, C = 1;
  //   cout << N << endl;
  //   for (int i = 0; i < N; ++i) {
  //     int T = (rand() & 1) + 1;
  //     cout << T << " " << (rand() % C) + 1 << endl;
  //     if (T == 1) ++C;
  //   }
  // }

  return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdlib>
#include<string>
#include<bitset>
#include<iomanip>
#define INF 1000000000
#define N 500005
#define K 44
#define P 1000000007
#define fi first
#define se second
#define debug(x) cout<<#x<<"="<<x<<endl
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
double dp[N],f[N][K+2];
char _ch;
inline void getint(int &_x)
{
	_x=0;
	for(_ch=getchar();_ch>'9'||_ch<'0';_ch=getchar());
	for(;_ch<='9'&&_ch>='0';_ch=getchar())
		_x=_x*10+_ch-48;
}

int fa[N],n=1;

void upd1(int x,int dep)
{
    int v=fa[x];
    if(v==0) return;
    if(v==1||dep==K)
    {
        for(int i=dep;i<=dep;i++)
            f[v][i]=f[v][i]/(0.5+0.5*f[x][i-1]);
        return;
    }
    upd1(fa[x],dep+1);
    for(int i=dep;i<=dep;i++)
        f[v][i]=f[v][i]/(0.5+0.5*f[x][i-1]);
}

void upd2(int x,int dep,double now)
{
    if(fa[x]==0||dep>K)
        return;
    int v=fa[x];
    now*=0.5*f[v][dep-1];
    //debug(x);
    //debug(now);
    //debug(f[v][1]);
    dp[v]+=now;
    for(int i=dep;i<=dep;i++)
        f[v][i]=f[v][i]*0.5+f[v][i]*f[x][i-1]*0.5;
    upd2(v,dep+1,now);
}

int main()
{
    int q,op,x;
    dp[1]=1;
    for(int i=1;i<=K;i++)
        f[1][i]=1;
    cin>>q;
    while(q--)
    {
        getint(op);
        if(op==1)
        {
            n++;
            getint(fa[n]);
            dp[n]=1;
            for(int i=1;i<=K;i++)
                f[n][i]=1;
            upd1(fa[n],3);
            upd2(n,2,1);
        }
        else
        {
            getint(x);
            printf("%.9f\n",dp[x]-1);
        }
    }
    return 0;
}
// davidlee1999WTK 2016/
// srO myk Orz
//ios::sync_with_stdio(false);
//#pragma comment(linker, "/STACK:102400000,102400000")  //compiler vc++
//#define O2 __attribute__((optimize("-O2")))

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<string>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,n) for(int i=1; i<=n; i++)

typedef long long LL;
using namespace std;

typedef pair<int,int> pii;
#define MP make_pair

#define M 50
#define N 500010

int n = 1, Q;
pii q[N];

int val[N];
#define lowbit(x) ((x)&(-(x)))
int getsum(int p){
    int ret= 0;
    while(p){
        ret += val[p];
        p-=lowbit(p);
    }
    return ret;
}
void add(int p){
    while(p<=n){
        val[p] ++;
        p += lowbit(p);
    }
}

vector<int> adj[N];
int dfn, L[N], R[N];
int fa[N];
void dfs(int u,int f){
    L[u] = ++dfn;
    for(auto &v : adj[u]){
        if(v == f)continue;
        fa[v] = u;
        dfs(v,u);
    }
    R[u] = dfn;
}

double fPow(double t,int p){
    double ret = 1;
    while(p){
        if(p&1)
            ret =ret * t;
        t = t * t;
        p >>=1;
    }
    return ret;
}

double dp[M+10];
int cnt[N][M+10];
double query(int u){
    //printf("2:%d\n",u);
    double ret = 0;
    int sz = getsum(R[u]) - getsum(L[u] - 1);
    memset(dp, 0, sizeof(dp));
    dp[M] = 1 - fPow( 1 - fPow(0.5, M), cnt[u][M]);
    ret += M * dp[M];
    for(int i = M-1; i>=1; i--){
        dp[i] = 1 - fPow( 1 - fPow(0.5, i), cnt[u][i]);
        ret += (dp[i] - dp[i+1]) * i;
    }
    return ret;
}
void insert(int u){
    //printf("1:%d\n",u);
    add(L[u]);
    int f = u;
    FOR(i,M){
        f = fa[f];
        cnt[f][i]++;
    }
}

int main(){
#ifdef QWERTIER
    freopen("in.txt","r",stdin);
#endif
    scanf("%d",&Q);
    FOR(i,Q){
        int op, u;
        scanf("%d%d",&op,&u);
        q[i] = MP(op,u);
        if(op == 1){
            q[i] = MP(op, ++n);
            adj[u].push_back(n);
        }else{
            q[i] = MP(op,u);
        }
    }
    dfs(1,0);
    add(1);
    FOR(i,Q){
        int op = q[i].first, u = q[i].second;
        if(op == 1)
            insert(u);
        else
            printf("%.10f\n", query(u));
    }
    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#define eps 1e-10
using namespace std;

const int maxn=500010;
int Q,n,type,u;
int fa[maxn];
double dp[maxn][41];

void read(int &num){
	num=0;char ch=getchar();
	while(ch<'!')ch=getchar();
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
}
void clear(int u,int v,int d){
	if(u==-1||d>40)return;
	clear(fa[u],u,d+1);
	if(fa[u]!=-1&&d<=39&&dp[u][d]>eps)dp[fa[u]][d+1]/=(0.5+0.5*dp[u][d]);
}
void Go(int u,int v,int d){
	if(u==-1||d>40)return;
	if(dp[u][d]<eps)dp[u][d]=1;
	if(d)dp[u][d]=dp[u][d]*(0.5+0.5*dp[v][d-1]);
	else dp[u][d]=dp[u][d]*0.5;
	Go(fa[u],u,d+1);
}
void Get_ans(int u){
	double ans=0;
	for(int i=40;i>=1;--i){
		if(dp[u][i]<eps)continue;
		ans=ans+(dp[u][i]-dp[u][i-1])*i;
	}printf("%.10lf\n",ans);
}

int main(){;
	read(Q);n=1;fa[1]=-1;dp[1][0]=1;
	while(Q--){
		read(type);read(u);
		if(type==1){
			++n;fa[n]=u;
			dp[n][0]=1;
			clear(fa[n],n,1);Go(fa[n],n,1);
			clear(fa[n],n,0);Go(fa[n],n,0);
		}else Get_ans(u);
	}return 0;
}

#include<cstdio>
#include<algorithm>
#ifndef GZOTPA
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif
#define N 500010
#define K 3
using namespace std;
int q,fa[N],n=1;
double f[N][K+5],pre[N];
int main()
{
	scanf("%d",&q);
	f[n][0]=1;
	int x,t,y;
	while(q--)
	{
		scanf("%d%d",&t,&x);
		if(t==1)
		{
			f[++n][0]=1;
			fa[n]=x;
			y=n;
			for(int i=1;x&&i<=K;i++,x=fa[x],y=fa[y])
			{
				debug("%.3lf %.3lf\n",pre[y],f[y][i-1]);
				pre[x]=f[x][i];
				f[x][i]=1.-(1.-f[x][i])*(.5+.5*(1.-f[y][i-1]))/(.5+.5*(1.-pre[y]));
			}
			debug("haha\n");
			for(int i=1;i<=n;i++)
			{
				for(int j=0;j<=K;j++)
				debug("%.3lf ",f[i][j]);
				debug("\n");
			}
		}
		else
		{
			double ans=0;
			for(int i=1;i<=K;i++)
			ans+=(f[x][i]-f[x][i+1])*i;
			printf("%.8lf\n",ans);
		}
	}
}

#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;

const int limite=500010;
const int H=28;

double error=1e-8;

int q;
int qt[limite],qu[limite];
vector<int> g[limite];
int numhijos[limite];
int padre[limite];
int ipadre[limite];
int amountP=0;
int iniP[limite];
double P[limite][H];
double SP[limite][H];

void genera(int u,int prof,int ind)
{
  if (H<=prof) return;
  int v=g[u][ind];
  double aux;
  aux=P[iniP[u]+ind][0];
  P[iniP[u]+ind][0]=0.5;
  if (aux>error)
    SP[u][0]*=P[iniP[u]+ind][0]/aux;
  for (int h=1;h<=prof;h++) {
    aux=P[iniP[u]+ind][h];
    P[iniP[u]+ind][h]=0.5+0.5*SP[v][h-1];
    if (aux>error)
      SP[u][h]*=P[iniP[u]+ind][h]/aux;
  }
  if (padre[u])
    genera(padre[u],prof+1,ipadre[u]);
}

int main()
{
  int n=1;
  scanf("%d",&q);
  for (int i=0;i<q;i++) {
    scanf("%d%d",&(qt[i]),&qu[i]);
    if (qt[i]==1) {
      n++;
      ipadre[n]=numhijos[qu[i]]++;
      padre[n]=qu[i];
      g[qu[i]].push_back(n);
      qu[i]=n;
    }
  }
  for (int i=1;i<=n;i++) {
    iniP[i]=amountP;
    amountP+=numhijos[i];
    for (int h=0;h<H;h++) {
      SP[i][h]=1;
      for (int j=0;j<numhijos[i];j++)
	P[iniP[i]+j][h]=1;
    }
  }
  for (int cas=0;cas<q;cas++) {
    int t=qt[cas];
    int u=qu[cas];
    if (t==1) {
      genera(padre[u],1,ipadre[u]);
    } else {
      double e=0;
      for (int h=1;h<H;h++)
	e+=h*(SP[u][h]-SP[u][h-1]);
      printf("%.10f\n",e);
    }
  }
}

#include<bits/stdc++.h>
typedef long double ld;
using namespace std;

const size_t DEEP = 35;

/*
void print(vector< vector<ld> > a, int x) {
    for (int i = 0; i < a[x].size(); ++i) {
        cerr << (double)a[x][i] << " ";
    }
    cerr << endl;
}
*/

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);

    int q;
    scanf("%d", &q);

    vector<int> pr(2);
    vector<vector<ld>> f(2);
    f[1] = vector<ld>(DEEP, 1.0);

    while (q--) {
        int type, v;
        scanf("%d%d", &type, &v);

        if (type == 1) {
            pr.push_back(v);
            f.push_back(vector<ld>(DEEP, 1.0));
            int x = pr.size() - 1;

            vector<int> prs(1, x);
            prs.reserve(DEEP + 1);

            for (size_t it = 1; it <= DEEP; ++it) {
                if (pr[prs.back()] == 0) break;
                prs.push_back(pr[prs.back()]);
            }

            for (int i = (int)prs.size() - 1; i > 1; --i) {
                int p = prs[i];
                int xx = prs[i - 1];

                for (size_t j = 0; j < DEEP; ++j) {
                   ld old;
                   if (j == 0)
                      old = 0.5;
                   else
                      old = f[xx][j - 1] + 0.5 * (1 - f[xx][j - 1]);

                   f[p][j] /= old;
                }
            }

            for (size_t i = 0; i + 1 < prs.size(); ++i) {
                int x = prs[i];
                int p = prs[i + 1];

                for (size_t j = 0; j < DEEP; ++j) {
                    ld nw;
                    if (j == 0)
                        nw = 0.5;
                    else
                        nw = f[x][j - 1] + 0.5 * (1 - f[x][j - 1]);

                    f[p][j] *= nw;
                }
            }

        } else {
//            cout << "ask" << endl;

            ld ans = 0;
            for (size_t i = 1; i < DEEP; ++i) {
                ans += (f[v][i] - f[v][i - 1]) * i;
            }

            printf("%.12f\n", (double)ans);
        }

        /*
        for (int x = 1; x < f.size(); ++x) {
            cout << x << ": ";
            for (int j = 0; j < DEEP; ++j) {
                cout << (double)f[x][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
        */
    }

//    cerr << clock() << endl;

    return 0;
}

#include <cstdio>
#include <cctype>
#include <assert.h>
#include <algorithm>
#define gc() getchar()
#define MAX_H 60
const int N=5e5+5;

int n,fa[N];
double f[N][MAX_H];

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now;
}

int main()
{
	n=1;
	for(int i=0; i<MAX_H; ++i) f[1][i]=1;
	for(int T=read(), Q=read(); Q--; )
	{
		int opt=read(),x=read();
		if(opt==1)
		{
			fa[++n]=x;
			for(int i=0; i<MAX_H; ++i) f[n][i]=1;
			double tmp1=f[x][0],tmp2;
			f[x][0]*=0.5;
			for(int Fa=fa[x],i=1; Fa&&i<MAX_H; Fa=fa[x=Fa],++i)
			{
				tmp2=f[Fa][i];
				f[Fa][i] /= 0.5 + 0.5*tmp1;
				f[Fa][i] *= 0.5 + 0.5*f[x][i-1];
				tmp1=tmp2;
			}
		}
		else
		{
			double ans=0; assert(x<=n);
			for(int i=1; i<MAX_H; ++i) ans+=(f[x][i]-f[x][i-1])*i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long double ld;
const int N=500010;
ld dp[N][40];int fa[N];int tot=1;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j;ld pre,last;int q;int opt,x;
	rep(i,0,30)	dp[1][i]=1;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&opt,&x);
		if(opt==1){
			tot++;fa[tot]=x;
			pre=dp[x][0];dp[x][0]*=0.5;
			rep(i,0,30)	dp[tot][i]=1;
			for(j=1;j<=30&&fa[x];j++,x=fa[x]){
				last=dp[fa[x]][j];dp[fa[x]][j]=dp[fa[x]][j]/(1+pre)*(1+dp[x][j-1]);pre=last;
			}
		}
		else{
			ld ans=0;
			rep(i,1,30)	ans+=i*(dp[x][i]-dp[x][i-1]);
			printf("%.8lf\n",(double)(ans));
		}
	}
}

#include <bits/stdc++.h> // PLEASE

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 500005
#define MAXM 60
#define MAXP 22
#define INF 2000100000
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll MOD = 1e9+7;
int Q;
int N = 1;
double dp[MAXN][MAXM];
int par[MAXN];

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> Q;
	dp[1][0] = 1.0;
	for(int i=0; i<Q; i++) {
		int t, x;
		cin >> t >> x;
		if(t == 1) {
			par[++N] = x;
			dp[N][0] = 1.0;
			int cur = x;
			int ch = N;
			double v = 0;
			for(int j=1; cur != 0 && j<MAXM; j++) {
				double mul = 1.0 - dp[cur][j];
				mul /= (0.5 + 0.5 * (1-v));
				mul *= (0.5 + 0.5 * (1-dp[ch][j-1]));
				v = dp[cur][j];
				dp[cur][j] = 1.0-mul;
				ch = cur;
				cur = par[cur];
			}
		}
		else {
			double ret = 0;
			for(int i=1; i<MAXM; i++) ret += dp[x][i];
			cout << ret << endl;
		}
	}
}

#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;

const int limite=500010;
const int H=30;

double error=1e-8;

int q;
int qt[limite],qu[limite];
vector<int> g[limite];
int numhijos[limite];
int padre[limite];
int ipadre[limite];
int amountP=0;
int iniP[limite];
double P[limite][H];
double SP[limite][H];

void genera(int u,int prof,int ind)
{
  if (H<=prof) return;
  int v=g[u][ind];
  double aux;
  aux=P[iniP[u]+ind][0];
  P[iniP[u]+ind][0]=0.5;
  if (aux>error)
    SP[u][0]*=P[iniP[u]+ind][0]/aux;
  for (int h=1;h<=prof;h++) {
    aux=P[iniP[u]+ind][h];
    P[iniP[u]+ind][h]=0.5+0.5*SP[v][h-1];
    if (aux>error)
      SP[u][h]*=P[iniP[u]+ind][h]/aux;
  }
  if (padre[u])
    genera(padre[u],prof+1,ipadre[u]);
}

int main()
{
  int n=1;
  scanf("%d",&q);
  for (int i=0;i<q;i++) {
    scanf("%d%d",&(qt[i]),&qu[i]);
    if (qt[i]==1) {
      n++;
      ipadre[n]=numhijos[qu[i]]++;
      padre[n]=qu[i];
      g[qu[i]].push_back(n);
      qu[i]=n;
    }
  }
  for (int i=1;i<=n;i++) {
    iniP[i]=amountP;
    amountP+=numhijos[i];
    for (int h=0;h<H;h++) {
      SP[i][h]=1;
      for (int j=0;j<numhijos[i];j++)
	P[iniP[i]+j][h]=1;
    }
  }
  for (int cas=0;cas<q;cas++) {
    int t=qt[cas];
    int u=qu[cas];
    if (t==1) {
      genera(padre[u],1,ipadre[u]);
    } else {
      double e=0;
      for (int h=1;h<H;h++)
	e+=h*(SP[u][h]-SP[u][h-1]);
      printf("%.10f\n",e);
    }
  }
}

#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

double dp[500010][32];
int fa[500010];

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int q;scanf("%d",&q);
	for (int i=0;i<=30;i++) dp[1][i]=1;
	int n=1;
	while (q--)
	{
		int op,x;scanf("%d%d",&op,&x);
		if (op==1)
		{
			fa[++n]=x;
			for (int j=0;j<=30;j++) dp[n][j]=1;
			double pre=dp[x][0];dp[x][0]/=2;double now=pre/2;
			x=fa[x];
			for (int i=1;x&&i<=30;i++,x=fa[x])
			{
				double t=dp[x][i];
				dp[x][i]=dp[x][i]*(now+1)/(pre+1);
				pre=t;
				now=dp[x][i];
			}
		}
		else
		{
			double ans=0;
			for (int i=1;i<=30;i++) ans=ans+(dp[x][i]-dp[x][i-1])*i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cassert>
#include <map>
#include <string>
#include <iomanip>
#include <set>
#include <queue>
#include <ctime>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define sz(v) (int)(v).size()
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long double LD;
//typedef long long LL;

const int N = 500007;
const int K = 20;

LD dp[K][N], tmp[K], old_dp[K];
int next_node=2, par[N];
bool random = false;

void get(int &ty, int &u) {
    if (random) {
        ty = rand() % 2 + 1;
        u = next_node -1- rand() % 1;
        if (u < 0) u = 1;
    }
    else {
        scanf("%d%d", &ty, &u);
    }
}

void solve() {
    srand(time(0));
    FOR(h, K) dp[h][1] = 1.0;
    int q;
    scanf("%d", &q);
    while(q--) {
        int ty, u;
        get(ty, u);
        if (ty == 1) {
            int new_node = next_node++;
            par[new_node] = u;
            FOR(h, K) dp[h][new_node] = 1.0;
            int son = new_node;
            FOR(iter, K) {
                if (u == 0) break;

                FOR(h, K) tmp[h] = dp[h][u];

                FOR(h, K) {
                    if (son == new_node) {
                        dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0));
                    }
                    else {
                        dp[h][u] /= (0.5 + 0.5 * (h ? old_dp[h-1]:0.0));
                        dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0));
                    }
                }

                FOR(h, K) old_dp[h] = tmp[h];
                son = u;
                u = par[u];
            }
        }
        if (ty == 2) {
            LD ans = 0;
            FOR(h, K) {
                LD pr = (dp[h][u] - (h ? dp[h-1][u] : 0.0));
                ans += pr * h;
            }
            printf("%.9f\n", (double)ans);
        }
    }
}

void testgen() {
    FILE *f = fopen("input.txt", "w");
    srand(time(0));
    fclose(f);
}

int  main(int argc, char* argv[]) {
#ifdef harhro94
    //testgen();
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    #define task "estimate"
    //freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif

    solve();

#ifdef harhro94
    cerr << "\ntime = " << clock() / 1000.0 << endl;
#endif
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n = 100;
    ll q;
    cin >> q;
    vector<vector<float>> a((size_t) n + 1, vector<float>((size_t) q + 1, 1));
    vector<ll> b((size_t) q + 1, -1);
    for (ll t = 0, z = 1; t < q; t++) {
        ll x, y;
        cin >> x >> y;
        y--;
        if (x == 1) {
            vector<ll> c;
            for (ll i = y, j = 1; i != -1 && j <= n; i = b[i], j++) {
                c.push_back(i);
            }
            for (ll i = (ll) c.size() - 1; i >= 1; i--) {
                a[i][c[i]] /= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            b[z] = y;
            a[0][y] *= 0.5;
            for (ll i = 1; i < (ll) c.size(); i++) {
                a[i][c[i]] *= 0.5 + a[i - 1][c[i - 1]] * 0.5;
            }
            z++;
        }
        if (x == 2) {
            float j = 0;
            for (ll i = 0; i <= n; i++) {
                j += (a[i][y] - (i == 0 ? 0 : a[i - 1][y])) * i;
            }
            cout << setprecision(100) << j << "\n";
            cout.flush();
        }
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

double f[510000][31];
int fa[510000], son[510000];

double pow_mod(double a, int k) {
	double ans = 1.0;
	while(k) {
		if(k & 1) ans *= a;
		a *= a; k /= 2;
	} return ans;
}

int main() {
	int n = 1;
	for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
	int Q = read();
	for(int i = 1; i <= Q; i++) {
		int opt = read(), x = read();
		if(opt == 1) {
			n++; fa[n] = x;
			son[x]++;
			for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
			double last = f[x][0];
			f[x][0] = pow_mod(0.5, son[x]);
			for(int i = 1; i <= 30; i++) {
				if(x == 1) break;
				int u = fa[x];
				double hh = f[u][i];
				f[u][i] /= (0.5 + 0.5 * last);
				f[u][i] *= (0.5 + 0.5 * f[x][i - 1]);
				x = u; last = hh;
			}
		} else {
			double ans = 0.0;
			for(int i = 1; i <= 30; i++) ans += (double)i * (f[x][i] - f[x][i - 1]);
			printf("%.6lf\n", ans);
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define re register
#define il inline
#define rep(i,a,b) for(re int i=(a);i<=(b);++i)
const int N =500005;
int Q,n,h[N*2],nxt[N*2],to[N*2],gr;
il void tu(int x,int y){to[++gr]=y,nxt[gr]=h[x],h[x]=gr;}
int fa[N];
typedef double db;
db f[N][65],ans;
const db eps =1e-6;
void find(int u,int j,db pre){
	if(!fa[u]||j>60)return;
	db tmp=f[fa[u]][j+1];
	if(f[fa[u]][j+1]>eps)f[fa[u]][j+1]*=(f[u][j]+1)/(pre+1);
	else f[fa[u]][j+1]=(f[u][j]+1)/(pre+1);
	find(fa[u],j+1,tmp);
}
int main(){
	scanf("%d",&Q);
	int op,ff;n=1;
	rep(i,0,60)
	f[1][i]=1;
	while(Q--){
		scanf("%d%d",&op,&ff);
		if(op==1){
			fa[++n]=ff;
			rep(i,0,60)
			f[n][i]=1;
			f[ff][0]*=0.5;
			find(ff,0,f[ff][0]*2);
		}
		else{
			ans=0;
			rep(i,1,60){
				if(f[ff][i]<eps)break;
				ans+=(f[ff][i]-f[ff][i-1])*i;
			}
			printf("%lf\n",ans);
		}
	}
	return 0;
}

//Have a nice day:)
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2147483647;
#define LL long long

inline int read();

const int N=5e5+2;
const int H=30;
int n, c;
double pre, now;
int f[N];
double dp[N][H+2];

void Insert(int x)
{
    f[++c]=x;
    for(int i=0; i<=H; ++i) dp[c][i]=1;
    if(x) pre=dp[x][0], dp[x][0]*=0.5;
    for(int i=1, y=x; i<=H; ++i)
    {
        int p=f[y]; if(!p) break;
        now=dp[p][i];
        dp[p][i]=dp[p][i]/(0.5+0.5*pre)*(0.5+0.5*dp[y][i-1]);
        pre=now; y=f[y];
    }
}

void Query(int x)
{
    double ans=0;
    for(int i=1; i<=H; ++i) ans+=(dp[x][i]-dp[x][i-1])*i;
    printf("%.10lf\n", ans);
}

void Work()
{
    n=read(); Insert(0);
    for(int i=1; i<=n; ++i)
        if(read()==1) Insert(read());
        else Query(read());
}

int main()
{
    #ifdef gc
    freopen("643e.in","r",stdin);
    freopen("643e.out","w",stdout);
    #endif

    Work();

    return 0;
}

inline int read()
{
    char c; bool type=1;
    while((c=getchar())<'0' || c>'9')
        if(c=='-') type=0;
    int ans=c^48;
    while((c=getchar())>='0' && c<='9')
        ans=(ans<<3)+(ans<<1)+(c^48);
    return type?ans:-ans;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=50;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}
			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				for(int j=0; j<=i; j++) ps[i][j] = sum[now][j];
				prev = now;
				now = parent[now];
			}

			prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					if(ps[i-1][j-1]>0.0000000000001)
					sum[now][j]/=(0.5+0.5*ps[i-1][j-1]);
					sum[now][j]*=(0.5+0.5*sum[prev][j-1]);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
//#define endl '\n'
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define PI  3.141592653589793238
#define MOD ((ll)1e9 + 7)
#define INF ((int)1e9)
#define EPS 1e-14
#define MAXN 500020
double dp[MAXN][61];
int par[MAXN];
int D[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);//  flush(cout);
#endif
    int n;
    scanf("%d",&n);

    fill(par,par+MAXN,-1);
    int c = 1;
    fill(&dp[0][0],&dp[0][0]+MAXN*61,1);

    rep (i,0,n) {
        int type =0;
        int parent;
        scanf("%d%d",&type,&parent);
        parent--;
        int vert = parent;

        if (type==1) {
            int child = c;
            c++;
            int depth = 0;
            par[child] = parent;
            double old =0;
            while (depth<=60) {
                double old1 = dp[parent][depth];
                if (depth-1 >= 0)
                    dp[parent][depth] /= 0.5*(1+old);
                D[parent] =  max(D[parent],depth+1);
                depth++;
                old=old1;
                child = parent;
                parent = par[parent];
                if (parent==-1)break;
            }
            depth=0;
            parent = vert;
            while (  depth<=60) {
                if (depth-1 >= 0)
                    dp[ parent][depth] *= 0.5*(1+dp[child][depth-1]);
                else
                    dp[parent][depth] *= 0.5;
                child = parent;
                parent = par[parent];
                if (parent==-1)break;
                depth++;
            }
        } else {
            double ans = 0;
            for (int d = D[parent];d>0;d--) {
                ans += d*(dp[parent][d]-dp[parent][d-1]);
            }
            parent = par[parent];

            printf("%.9f\n",ans);
        }
    }

    return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=58;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}

			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				ps[i][0] = sum[now][0];
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					ps[i][j] = sum[now][j];
					if(ps[i-1][j-1]!=0)
						sum[now][j]/=(0.5+ps[i-1][j-1]/2);
					sum[now][j]*=(0.5+sum[prev][j-1]/2);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			ans+=(M+1)*(1-sum[v][M]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include"bits/stdc++.h"
#include<valarray>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int q;

int cur;

#define MAX 500002

vector<int> v[MAX];
int pr[MAX];
int dep[MAX];

double dp[MAX][60];

int main(){
	cin>>q;
	for(int ii=0;ii<q;ii++){
		int ty;
		scanf("%d",&ty);
		if(ty==1){
			cur++;
			int par;
			scanf("%d",&par);
			par--;
			v[par].push_back(cur);
			pr[cur]=par;
			dep[cur]=dep[par]+1;
			dp[cur][0]=1.0;
			int pos=cur;
			int tim=60;
			while(tim--){
				if(pos==0)break;
				int child=pos;
				pos=pr[pos];
				for(int j=0;j<60;j++){
					dp[pos][j]=0;
				}
				dp[pos][0]=1;
				for(int el:v[pos]){
					for(int j=99;j>=1;j--){
						dp[pos][j]+=dp[el][j-1]*0.5*(1.0-dp[pos][j]);
						/*if(j==1){
							cout<<dp[pos][j]<<endl;
						}*/
					}
				}
			}
		}
		else{
			int node;
			scanf("%d",&node);
			node--;
			double ans=0;
			for(int j=1;j<60;j++){
				ans+=dp[node][j];
			}
			printf("%.16f\n",ans);
		}
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cassert>
#include <map>
#include <string>
#include <iomanip>
#include <set>
#include <queue>
#include <ctime>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define sz(v) (int)(v).size()
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef double LD;
//typedef long long LL;

const LD eps = 1e-10;
const int N = 500007;
const int K = 32;

LD dp[K][N], tmp[K], old_dp[K];
int next_node=2, par[N];
bool random = false;

void get(int &ty, int &u) {
    if (random) {
        ty = rand() % 2 + 1;
        //u = next_node - 2- rand() % 1;
        u = rand() % (next_node-1)+1;
        if (u < 0) u = 1;
    }
    else {
        scanf("%d%d", &ty, &u);
    }
}

void solve() {
    srand(time(0));
    FOR(h, K) dp[h][1] = 1.0;
    int q;
    scanf("%d", &q);
    while(q--) {
        int ty, u;
        get(ty, u);
        if (ty == 1) {
            int new_node = next_node++;
            par[new_node] = u;
            FOR(h, K) dp[h][new_node] = 1.0;
            int son = new_node;
            FOR(h, K) {
                if (u == 0) break;

                tmp[h] = dp[h][u];

                if (son == new_node) {
                    dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0));
                }
                else {
                    dp[h][u] *= (0.5 + 0.5 * (h ? dp[h-1][son]:0.0))/(0.5 + 0.5 * (h ? old_dp[h-1]:0.0));
                }

                old_dp[h] = tmp[h];
                son = u;
                u = par[u];
            }
        }
        if (ty == 2) {
            LD ans = 0;
            FOR(h, K) {
                LD pr = (dp[h][u] - (h ? dp[h-1][u] : 0.0));
                ans += pr * h;
            }
            printf("%.9f\n", (double)ans);
        }
    }
}

void testgen() {
    FILE *f = fopen("input.txt", "w");
    srand(time(0));
    fclose(f);
}

int  main(int argc, char* argv[]) {
#ifdef harhro94
    //testgen();
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    #define task "estimate"
    //freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif

    solve();

#ifdef harhro94
    cerr << "\ntime = " << clock() / 1000.0 << endl;
#endif
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define N 500500
#define L 30
#define ep 1e-8

int q, n, pa[N], d[N];
double f[N][L], tmp[L], ttmp[L];

void update(int x) {
	f[x][0] = 1.;
	int y = pa[x], k = d[y];
	tmp[0] = 1.;
	for(int i = 1; i < L; i ++) {
		tmp[i] = 2. - f[y][i];
		f[y][i] = 1. - (1. - f[y][i]) * (1. - f[x][i-1] * 0.5);
		tmp[i] = (2. - f[y][i]) / tmp[i];
	}
	x = y;
	for(int j = 1; j < L && pa[x]; j ++) {
		y = pa[x];
		k = d[y];
		for(int i = 1; i < L; i ++) {
			ttmp[i] = 2. - f[y][i];
			f[y][i] = 1. - (1. - f[y][i]) * tmp[i - 1];
			ttmp[i] = (2. - f[y][i]) / ttmp[i];
		}
		for(int i = 1; i < L; i ++) tmp[i] = ttmp[i];
		x = y;
	}
}

void query(int type, int v) {
	if(type == 1) {
		++ n;
		pa[n] = v; d[v] ++;
		update(n);
	} else {
		double ans = 0.;
		for(int i = 1; i < L; i ++) ans += f[v][i];
		printf("%.10lf\n", ans);
	}
}

void input(int &x) {
	x = 0;
	char c = getchar();
	while(c <= 32) c = getchar();
	while(c > 32) x = x * 10 + (c ^ 48), c = getchar();
}

int main() {
	//freopen("in.txt", "r", stdin);
	n = 1;
	input(q);
	while(q --) {
		int type, v;
		input(type); input(v);
		query(type, v);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 100005,M = 60;
int q,fa[N],n = 1;
double dp[N][M + 5];
int main ()
{
    ios::sync_with_stdio(false);
    cin >> q;
    int opt,pos;
    for (int i = 0;i <= M;i++) dp[1][i] = 1;
    for (int _ = 1;_ <= q;_++)
    {
        cin >> opt >> pos;
        if (opt == 1)
        {
            fa[++n] = pos;
            for (int i = 0;i <= M;i++) dp[n][i] = 1;
            double pre = 1;int pp = n;
            for (int i = 0,cur = pos;cur && i <= M;i++,cur = fa[cur])
            {
                double tmp = dp[cur][i];
                dp[cur][i] /= 0.5 * (pre + 1);
                if (i) dp[cur][i] *= 0.5 * (1 + dp[pp][i - 1]);
                else dp[cur][i] *= 0.5;
                pp = cur;pre = tmp;
            }
        }
        else
        {
            double ans = 0;
            for (int i = 1;i <= M;i++)
                ans += (dp[pos][i] - dp[pos][i - 1]) * i;
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}
//一道需要忽略误差的题......

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

double f[510000][31];
int fa[510000], son[510000];

double pow_mod(double a, int k) {
	double ans = 1.0;
	while(k) {
		if(k & 1) ans *= a;
		a *= a; k /= 2;
	} return ans;
}

int main() {
	int n = 1;
	for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
	int Q = read();
	for(int i = 1; i <= Q; i++) {
		int opt = read(), x = read();
		if(opt == 1) {
			n++; fa[n] = x;
			son[x]++;
			for(int i = 0; i <= 30; i++) f[n][i] = 1.0;
			double last = f[x][0];
			f[x][0] = pow_mod(0.5, son[x]);
			for(int i = 1; i <= 30; i++) {
				if(x == 1) break;
				int u = fa[x];
				double hh = f[u][i];
				f[u][i] /= (0.5 + 0.5 * last);
				f[u][i] *= (0.5 + 0.5 * f[x][i - 1]);
				x = u; last = hh;
			}
		} else {
			double ans = 0.0;
			for(int i = 1; i <= 30; i++) ans += (double)i * (f[x][i] - f[x][i - 1]);
			printf("%.10lf\n", ans);
		}
	}
	return 0;
}

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const ll INF=1<<28;
const ll LINF=1ll<<61;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c!=' '&&c!='\n')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int q,p[500111],tot;
double dp[500111][32],sum[500111][32];
void del(int x,int y)//remove son y from x
{
	double t=1.0/2;
	for(int i=0;i<30;i++)
	{
		sum[x][i]/=t;
		t+=dp[y][i]/2;
	}
}
void add(int x,int y)//add son y to x
{
	double t=1.0/2;
	for(int i=0;i<30;i++)
	{
		sum[x][i]*=t;
		t+=dp[y][i]/2;
	}
}
void update(int x)
{
	dp[x][0]=sum[x][0];
	for(int i=1;i<30;i++)dp[x][i]=sum[x][i]-sum[x][i-1];
}
int main()
{
	tot++;
	p[1]=-1;
	for(int i=0;i<30;i++)sum[1][i]=1;
	update(1);
	geti(q);
	while(q--)
	{
		int type,x;
		getii(type,x);
		if(type==1)
		{
			int tx=x;
			tot++;
			p[tot]=x;
			for(int i=0;i<30;i++)sum[tot][i]=1;
			update(tot);
			x=tx;
			for(int i=1;p[x]!=-1&&i<30;i++,x=p[x])
			{
				del(p[x],x);
			}
			x=tx;
			add(x,tot);
			update(x);
			for(int i=1;p[x]!=-1&&i<30;i++,x=p[x])
			{
				add(p[x],x);
				update(p[x]);
			}
		}
		else
		{
			double ans=0;
			for(int i=1;i<30;i++)ans+=dp[x][i]*i;
			printf("%.8lf\n",ans);
		}
//		for(int i=1;i<=tot;i++)see(i);
	}
	return 0;
}

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <ctime>
#include <string>
#include <queue>

using namespace std;

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;

long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}

inline int myrand() {
#ifdef _WIN32
  return abs((rand() << 15) ^ rand());
#else
  return rand();
#endif
}

inline int rnd(int x) {
  return myrand() % x;
}

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define TASKNAME "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

int q;

int read() {
  if (scanf("%d", &q) < 1) {
    return 0;
  }
  return 1;
}

const int maxn = (int) 5e5 + 10, maxt = 30;
int pr[maxn];
ld dp[maxn][maxt];
ld ans[maxn];

int n;

void addv(int prev) {
  pr[n] = prev;
  for (int i = 1; i < maxt; ++i) {
    dp[n][i] = 2;
  }
  dp[n][0] = 1;
  ans[n] = 0;
  ++n;
}

void solve() {
  n = 0;
  addv(-1);
  for (int iter = 0; iter < q; ++iter) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int v;
      scanf("%d", &v);
      --v;
      addv(v);

      ld last = 1, waslast = 2;
      for (int iter = 1; v >= 0 && iter < maxt; ++iter, v = pr[v]) {
        ld waswaslast = waslast;
        waslast = dp[v][iter];
        ans[v] += waslast;
        last = (dp[v][iter] = (((waslast - 1) * last / waswaslast) + 1));
        ans[v] -= last;
      }
    } else {
      int v;
      scanf("%d", &v);
      --v;
      printf("%.18f\n", (double) ans[v]);
    }
  }
}

int main() {
  srand(rdtsc());
  precalc();
#ifdef LOCAL
  freopen(TASKNAME".out", "w", stdout);
  assert(freopen(TASKNAME".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

//Start
typedef long long ll;
typedef double db;
#define mp(a,b) make_pair(a,b)
#define x first
#define y second
#define b(a) a.begin()
#define e(a) a.end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

//Read
const int L=1e6; char buf[L],*bs,*bt;
char fr(){
	if(bs==bt){
		bt=(bs=buf)+fread(buf,1,L,stdin);
		if(bs==bt)return EOF;
	}
	return *bs++;
}
template<class T>T read(){
	T x=0,f=1; char c=fr();
	for(;!isdigit(c);c=fr())if(c=='-') f=-1;
	for(;isdigit(c);c=fr()) x=10*x+c-48;
	return x*f;
}
#define ri read<int>()
#define rl read<ll>()

//Data
const int N=5e5,D=1;
int n,fa[N+7];
db f[N+7][D+7],son[N+7][D+7];
void wen(int u){for(int i=0;i<=D;i++) f[u][i]=son[u][i]=1;}

//Main
int main(){
//	freopen("62d.out","r",stdin);
	int q=ri; wen(n=1);
	for(int ti=1;ti<=q;ti++){
		int o=ri,r=ri;
		if(o==1){
			int u=++n; wen(u),fa[u]=r;
//			int cnt=0;
			for(int v=u,d=0;v&&d<=D;v=fa[v],d++){
//				if(++cnt>60) puts("VAR");
				for(int i=0;i<=D;i++) son[fa[v]][i]/=(f[v][i]+1)/2;
				if(v==r) f[v][0]/=2; son[fa[v]][0]*=(f[v][0]+1)/2;
				for(int i=1;i<=D;i++){
					if(i==1) f[v][i]=son[v][0];
					else f[v][i]=f[v][i-1]+son[v][i-1]-son[v][i-2];
					son[fa[v]][i]*=(f[v][i]+1)/2;
				}
			}
		} else {
			db res=0;
			for(int i=1;i<=D;i++) res+=(f[r][i]-f[r][i-1])*i;
			printf("%.10lf\n",res);
		}
//		if(ti%1000==0) printf("%d\n",ti);
	}
	return 0;
}

#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

double dp[500010][32];
int fa[500010];

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int q;scanf("%d",&q);
	for (int i=0;i<=30;i++) dp[1][i]=1;
	int n=1;
	while (q--)
	{
		int op,x;scanf("%d%d",&op,&x);
		if (op==1)
		{
			fa[++n]=x;
			for (int j=0;j<=30;j++) dp[n][j]=1;
			double pre=dp[x][0];dp[x][0]/=2;double now=pre/2;
			x=fa[x];
			for (int i=1;x&&i<=30;i++,x=fa[x])
			{
				double t=dp[x][i];
				dp[x][i]=dp[x][i]*(now+1)/(pre+1);
				pre=t;
				now=dp[x][i];
			}
		}
		else
		{
			double ans=0;
			for (int i=1;i<=30;i++) ans=ans+(dp[x][i]-dp[x][i-1])*i;
			printf("%.10lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

const int N = (int)5e5 + 10;
const int K = 10;
typedef double T;
T dp[N][K];
int par[N];

void solve (int n)
{
    int curv = 2;
    memset(dp, 0, sizeof dp);
    for (int i = 1; i < K; i++)
        dp[1][i] = 1.0;
    par[1] = -1;

    for (int i = 0; i < n; i++)
    {
        int type, v;
        cin >> type >> v;

        if (type == 1)
        {
            par[curv] = v;
            dp[curv][0] = 0.0;
            for (int i = 1; i < K; i++)
                dp[curv][i] = 1.0;

            assert(par[curv] == v);
            T old_val = dp[v][1];
            dp[v][1] *= (0.5 + 0.5 * dp[curv][0]);

            int cv = v;
            for (int i = 2; i < K; i++)
            {
                int u = par[cv];
                assert(u != 0);
                if (u == -1)
                    break;

                T nold = dp[u][i];
                dp[u][i] /= (0.5 + 0.5 * old_val);
                dp[u][i] *= (0.5 + 0.5 * dp[cv][i - 1]);
                old_val = nold;
                cv = u;
            }

            curv++;
        }
        else
        {
            T ans = 0;
            for (int i = 1; i < K; i++)
            {
                //cerr << dp[v][i] << ' ';
                ans += (1.0 - dp[v][i]);
            }
            //cerr << endl;
            printf("%.12f\n", (double)ans);
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while (cin >> n)
        solve(n);
}

#include<bits/stdc++.h>
using namespace std;
#define re register
#define il inline
#define rep(i,a,b) for(re int i=(a);i<=(b);++i)
const int N =500005;
int Q,n,h[N*2],nxt[N*2],to[N*2],gr;
il void tu(int x,int y){to[++gr]=y,nxt[gr]=h[x],h[x]=gr;}
int fa[N];
typedef double db;
db f[N][65],ans;
const db eps =1e-6;
void find(int u,int j,db pre){
	if(!fa[u]||j>60)return;
	db tmp=f[fa[u]][j+1];
	if(f[fa[u]][j+1]>eps)f[fa[u]][j+1]*=(f[u][j]+1)/(pre+1);
	else f[fa[u]][j+1]=(f[u][j]+1)/(pre+1);
	find(fa[u],j+1,tmp);
}
int main(){
	scanf("%d",&Q);
	int op,ff;n=1;
	rep(i,0,60)
	f[1][i]=1;
	while(Q--){
		scanf("%d%d",&op,&ff);
		if(op==1){
			fa[++n]=ff;
			rep(i,0,60)
			f[n][i]=1;
			f[ff][0]*=0.5;
			find(ff,0,f[ff][0]*2);
		}
		else{
			ans=0;
			rep(i,1,60){
				if(f[ff][i]<eps)break;
				ans+=(f[ff][i]-f[ff][i-1])*i;
			}
			printf("%lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = l; i < r; i++)
#define FST first
#define SCD second
#define modp  1000000007
#define MAXN 500113
#define MAXL 61
#define EPS 1e-7
using namespace std;

typedef long long LL;
typedef unsigned int UI;

int Q;
double dp[MAXN][MAXL];
int ml[MAXN];
int f[MAXN];
void update(int v, double pre, double cur, int l)
{
    if (l == MAXL || v == 0) {
        return;
    }
    if (l >= ml[v]) {
        ml[v]++;
        dp[v][l] = 1;
    }
    double tmp = dp[v][l];
    dp[v][l] *= (1 + cur) / (1 + pre);
    update(f[v], tmp, dp[v][l], l + 1);
}

int main()
{
    scanf("%d", &Q);
    int k = 1;
    dp[0][0] = 1;
    FOR(i, 0, Q) {
        int t, v;
        scanf("%d%d", &t, &v);
        if (t == 1) {
            f[++k] = v;
            dp[k][0] = 1;
            update(v, 1, 0, 0);
        }
        else {
            double S = 0;
            FOR(i, 0, MAXL) {
                if (i >= ml[v]) {
                    dp[v][ml[v]++] = 1;
                }
                if ((1 - dp[v][i]) * i < EPS) {
                    S += i * dp[v][i];
                    break;
                }
                S -= dp[v][i];
            }
            printf("%.12f\n", S);
        }
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <memory.h>

using namespace std;

int t[500005], v[500005];
vector<int> g[500005];

const int MAXP = 17;
const int N = MAXP;

struct SegmentTree {
  SegmentTree(int _n = 0) : n(_n) {
    init(_n);
  }

  void init(int _n) {
    n = _n;
    tree = vector<vector<double>>(n + 1, vector<double>(N, 1.0));

    // tree[n + 1] = vector<double>(N, 0);
    // tree[n + 1][0] = 1.0;
  }

  void update(int pos, const vector<double> &v, int where) {
    // for (int i = 1; i < v.size(); ++i)
    //   v[i] += v[i - 1];

    // for (int i = 0; i < tree[pos].size(); ++i) {
    //   tree[n][i] /= tree[pos][i];
    // }
    // for (int i = 0; i < v.size(); ++i) {
    //   tree[n][i] *= v[i];
    // }

    for (int i = where; i < tree[pos].size() && i <= where; ++i) {
      tree[n][i] /= tree[pos][i];
    }
    for (int i = where; i < v.size() && i <= where; ++i) {
      tree[n][i] *= v[i];
    }

    // for (int i = 0; i < N; ++i) {
    //   tree[n + 1][i] = tree[n][i] - (i > 0 ? tree[n][i - 1] : 0);
    // }
    tree[pos][where] = v[where];
  }

  vector<double>& get() {
    return tree[n];
  }

  int n;
  vector<vector<double>> tree;
};

SegmentTree Q[500005];

int par[500005], POS[500005];

int main() {
  Q[0].init(500000);
  int q;
  scanf("%d", &q);
  int cnt = 1;
  memset(par, -1, sizeof(par));
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &t[i], &v[i]); --v[i];
    if (t[i] == 1) {
      POS[cnt] = g[v[i]].size();
      g[v[i]].push_back(cnt);
      par[cnt] = v[i];
      ++cnt;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    Q[i].init(g[i].size());
  }

  cnt = 1;
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      vector<double> cur(N, 1.0);
      cur[0] = 0.5; cur[1] = 1.0;
      int x = cnt, it = 0, where = 0;
      while (par[x] != -1 && it < N) {
        ++it;
        // cout << x << "  " << par[x] << "  " << POS[x] << endl;
        Q[par[x]].update(POS[x], cur, where); ++where;
        x = par[x];
        // cur = Q[x].get();
        if (where < N)
          cur[where] = Q[x].get()[where - 1] * 0.5 + 0.5;
        // vector<double> tmp(1, 0.5);
        // for (int i = 0; i < cur.size() && i < N; ++i) {
        //   tmp.push_back(0.5 * cur[i] + 0.5);
        // }
        // cur = tmp;
      }
      ++cnt;
    } else {
      double ans = 0;
      vector<double> X = Q[v[i]].get();
      for (int j = 1; j < X.size(); ++j) {
        ans += j * (X[j] - X[j - 1]);
      }
      printf("%.10lf\n", ans);
    }
  }

  // {
  //   int N = 1000, C = 1;
  //   cout << N << endl;
  //   for (int i = 0; i < N; ++i) {
  //     int T = (rand() & 1) + 1;
  //     cout << T << " " << (rand() % C) + 1 << endl;
  //     if (T == 1) ++C;
  //   }
  // }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500000;
const int MAX_H = 64;

int n, p[MAX_N];
double f[MAX_N][MAX_H];

double ask(int v) {
    double sum = 0.0;
    for (int i = 1; i < MAX_H; ++i) {
        sum += (f[v][i] - f[v][i - 1]) * i;
    }
    return sum;
}

void add(int v) {
    ++n;
    p[n] = v;
    for (int i = 0; i < MAX_H; ++i) {
        f[n][i] = 1.0;
    }
    vector<int> ancestors;
    for (int i = 0, u = n; i < MAX_H && u != -1; ++i, u = p[u]) {
        ancestors.push_back(u);
    }
    for (int i = 2; i < MAX_H && i < (int)ancestors.size(); ++i) {
        f[ancestors[i]][i - 1] /= (1.0 + f[ancestors[i - 1]][ - 2]) / 2.0;
    }
    for (int i = 1; i < MAX_H && i < (int)ancestors.size(); ++i) {
        if (i == 1) {
            f[ancestors[i]][i - 1] *= 1.0 / 2.0;
        } else {
            f[ancestors[i]][i - 1] *= (1.0 + f[ancestors[i - 1]][i - 2]) / 2.0;
        }
    }
}

int main() {
    int q;
    cin >> q;

    n = 0;
    p[n] = -1;
    for (int i = 0; i < MAX_H; ++i) {
        f[n][i] = 1.0;
    }

    for (int i = 0; i < q; ++i) {
        int type, v;
        cin >> type >> v;
        --v;
        if (type == 1) {
            add(v);
        } else {
            cout << setprecision(12) << ask(v) << endl;
        }
    }

    return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=54;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}
			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				for(int j=0; j<=i; j++) ps[i][j] = sum[now][j];
				prev = now;
				now = parent[now];
			}

			prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					if(ps[i-1][j-1]!=0)
						sum[now][j]/=(0.5+0.5*ps[i-1][j-1]);
					sum[now][j]*=(0.5+0.5*sum[prev][j-1]);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAGIC = 33;
typedef double ld;

int q;
int on = 2;
int p[500013];
ld prod[500013][MAGIC];

int main() {
	for (int i=0;i<500013;i++) fill(prod[i],prod[i]+MAGIC,1);
	scanf("%d",&q);
	while (q--) {
		int type, v;
		scanf("%d%d",&type,&v);
		if (type==1) {
			p[on] = v;
			on+=1;
			vector<int> has;
			for (int r=0;r<MAGIC;r++) {
				if (!v) break;
				has.push_back(v);
				v = p[v];
			}
			for (int x: vector<int>(has.rbegin(),has.rend())) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]/=(0.5+prod[x][i-1]/2);
				}
			}
			prod[has[0]][0]/=2;
			for (int x: has) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]*=(0.5+prod[x][i-1]/2);
				}
			}
        } else {
			ld ans = 0;
			for (int i=1;i<MAGIC;i++) {
				ans+=i*(prod[v][i]-prod[v][i-1]);
			}
			printf("%1.9f\n",(double) ans);
		}
	}

	return 0;
}

#include"bits/stdc++.h"
#include<valarray>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int q;

int cur;

#define MAX 500002

vector<int> v[MAX];
int pr[MAX];
int dep[MAX];

double dp[MAX][60];

int main(){
	cin>>q;
	for(int ii=0;ii<q;ii++){
		int ty;
		scanf("%d",&ty);
		if(ty==1){
			cur++;
			int par;
			scanf("%d",&par);
			par--;
			v[par].push_back(cur);
			pr[cur]=par;
			dep[cur]=dep[par]+1;
			dp[cur][0]=1.0;
			int pos=cur;
			int tim=60;
			while(tim--){
				if(pos==0)break;
				int child=pos;
				pos=pr[pos];
				for(int j=0;j<60;j++){
					dp[pos][j]=0;
				}
				dp[pos][0]=1;
				for(int el:v[pos]){
					for(int j=99;j>=1;j--){
						dp[pos][j]+=dp[el][j-1]*0.5*(1.0-dp[pos][j]);
						/*if(j==1){
							cout<<dp[pos][j]<<endl;
						}*/
					}
				}
			}
		}
		else{
			int node;
			scanf("%d",&node);
			node--;
			double ans=0;
			for(int j=1;j<60;j++){
				ans+=dp[node][j];
			}
			printf("%.16f\n",ans);
		}
	}
	return 0;
}

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

const int MAXN = 500010;
const int MAXD = 100;

double p[MAXN][MAXD];
int fa[MAXN];
int q;

int main() {
    scanf("%d", &q);
    int n = 1;
    p[1][0] = 1.0;
    while (q-- > 0) {
        int type, v;
        scanf("%d%d", &type, &v);
        if (type == 1) {
            fa[++n] = v;
            int now = n;
            p[now][0] = 1.0;
            double p_old = 0.0;
            for (int i = 1; i < MAXD; ++i) {
                int next = fa[now];
                double p_new = 0.5 * (p[now][i - 1] - p_old) * (1.0 - (p[next][i] - 0.5 * p_old) / (1 - p_old));
                p_old = p[next][i];
                p[next][i] += p_new;
                if (now == 1) {
                    break;
                }
                now = next;
            }
        } else {
            double res = 0.0;
            for (int i = 1; i < MAXD; ++i) {//cerr << v << ' ' << p[v][i] << endl;
                res += p[v][i];
            }
            printf("%.10f\n", res);
        }
    }
}

#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 5e5+10;
const int CUT_OFF = 30;
double dp[SIZE][CUT_OFF],two[SIZE],tmp[CUT_OFF],tmp2[CUT_OFF];
int father[SIZE];
int id=2;
VI e[SIZE];
void update(int x,int from,int r){
    if(x==from){
        REP(i,CUT_OFF)dp[x][i]=1;
        REP(i,CUT_OFF)tmp[i]=dp[x][i];
    }
    else{
        REP(i,CUT_OFF)tmp2[i]=dp[x][i];
        dp[x][0]=two[SZ(e[x])];
        REPP(i,1,CUT_OFF){
            dp[x][i]=dp[x][i]*((1+dp[from][i-1])/(1+tmp[i-1]));
        }
        REP(i,CUT_OFF)tmp[i]=tmp2[i];
    }
    if(r&&x!=1)update(father[x],x,r-1);
}
int main(){
    two[0]=1;
    REPP(i,1,SIZE)two[i]=two[i-1]*0.5;
    REP(i,CUT_OFF)dp[1][i]=1;
    DRI(Q);
    while(Q--){
        DRII(ty,x);
        if(ty==1){
            int me=id++;
            father[me]=x;
            e[x].PB(me);
            update(me,me,CUT_OFF);
        }
        else{
            double an=0;
            REPP(i,1,CUT_OFF){
                an+=(dp[x][i]-dp[x][i-1])*i;
            }
            printf("%.12f\n",an);
        }
        //    REP(i,CUT_OFF)printf("%d:%f\n",i,dp[1][i]);
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &(x))
#define ld double
const int N = 500005;
const int logN = 35;
ld dp[logN][N], prevdp[logN][N];
int par[N];
int main(){
	int q, type, v, index = 1;
	for(int j = 1; j< logN; j++) dp[j][1] = 1.;
	sd(q);
	while(q--){
		sd(type), sd(v);
		if(type == 1){
			par[++index] = v; int p = v; v = index;
			for(int j = 1; j < logN; j++){
				dp[j][v] = 1.;
				prevdp[j][p] = dp[j][p];
				dp[j][p] *= (0.5 * (1 + dp[j - 1][v]));
			}
			int cnt = 2;
			int temp = par[p]; v = p; p = temp;
			while(p && cnt < logN){
				cnt ++;
				for(int j = 1; j < logN; j++){
					prevdp[j][p] = dp[j][p];
					dp[j][p] *= (1 + dp[j - 1][v]) / (1 + prevdp[j - 1][v]);
				}
				int temp = par[p]; v = p; p = temp;
			}
		}
		else{
			ld exp = 0;
			for(int i = 1; i < logN; i++){
				ld p = dp[i][v] - dp[i - 1][v];
				exp += p * i;
			}
			printf("%.10lf\n", exp - 1.);
		}
	}

}

#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
double dp[500100][32];
int num_q,v,flag,pa[501000],n,list[33],cnt_list,pw[501000];
int main()
{
	int i,j,s,p,q,id,ip;
	scanf("%d",&num_q);
	n=1;
	for(i=0;i<=30;i++)
	   dp[0][i]=1.;
	for(i=0;i<=500000;i++)
	{
		if(i==0)
		  pw[i]=1;
        else
          pw[i]=0.5*pw[i-1];
	}
	while(num_q--)
	{
		scanf("%d%d",&flag,&v);
		v--;
		if(flag==1)
		{
			pa[n++]=v;
			id=n-1;
		    cnt_list=0;
		    while(id!=0&&cnt_list<=30)
		    {
			    list[cnt_list++]=id;
			    id=pa[id];
    		}
    		if(cnt_list<=30)
    		  list[cnt_list++]=0;
  		  //  printf("cnt_list=%d\n",cnt_list);
    		for(i=cnt_list-1;i>0;i--)
    		{
		    	id=list[i];
		    	ip=list[i-1];
				for(j=1;j<i;j++)
				   dp[id][j]/=(dp[ip][j-1]*0.5+0.5);
			}
   			for(i=0;i<=30;i++)
			   dp[n-1][i]=1.;
			dp[v][0]*=0.5;
			for(i=1;i<cnt_list;i++)
		    {
    			id=list[i];
    			ip=list[i-1];
    			for(j=1;j<i;j++)
			    	dp[id][j]*=(dp[ip][j-1]*0.5+0.5);
		    //	if(i==2)
		    //	   printf("dp[%d][1]=%.20f\n",id,dp[id][1]);
		    //	if(i==2)
		    	//   printf("dp[%d][2]=%.20f\n",id,dp[id][i]);
    		}
		}
		else
		{
		    double ans=0;
		    for(i=1;i<=30;i++)
		    {
		       ans+=i*(dp[v][i]-dp[v][i-1]);
		    //   if(i==1)
		         // printf("orz=%.20f\n",dp[v][i]-dp[v][i-1]);
			}
			printf("%.20f\n",ans);
		}
	}
	return 0;
}

#include<stdio.h>
#include<algorithm>

using namespace::std;

const int N=500000, M=52;
int parent[N+2];
double sum[N+2][M+1];
int n,q;

int main(){
	scanf("%d",&q);
	n=1;
	for(int i=0; i<=M; i++)
		sum[1][i]=1.0;
	while(q--){
		int t,v;
		scanf("%d %d",&t,&v);
		if(t==1){
			parent[++n]=v;
			double ps[M+2][M+2];
			for(int i=0; i<=M; i++){
				ps[0][i] = sum[n][i];
				sum[n][i]=1.0;
			}
			int prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				for(int j=0; j<=i; j++) ps[i][j] = sum[now][j];
				prev = now;
				now = parent[now];
			}

			prev=n, now = v;
			for(int i=1; i<=M && now!=0; i++){
				if(i==1) sum[now][0]/=2;
				for(int j=1; j<=i; j++){
					if(ps[i-1][j-1]!=0)
					sum[now][j]/=(0.5+0.5*ps[i-1][j-1]);
					sum[now][j]*=(0.5+0.5*sum[prev][j-1]);
				}
				prev = now;
				now = parent[now];
			}
		}
		else{
			double ans=0.0;
			for(int i=1; i<=M; i++)
				ans+=i*(sum[v][i]-sum[v][i-1]);
			printf("%.9lf\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAGIC = 33;
typedef long double ld;

int q;
int on = 2;
int p[500013];
ld prod[500013][MAGIC];

int main() {
	for (int i=0;i<500013;i++) fill(prod[i],prod[i]+MAGIC,1);
	scanf("%d",&q);
	while (q--) {
		int type, v;
		scanf("%d%d",&type,&v);
		if (type==1) {
			p[on] = v;
			on+=1;
			vector<int> has;
			for (int r=0;r<MAGIC;r++) {
				if (!v) break;
				has.push_back(v);
				v = p[v];
			}
			for (int x: vector<int>(has.rbegin(),has.rend())) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]/=(0.5+prod[x][i-1]/2);
				}
			}
			prod[has[0]][0]/=2;
			for (int x: has) {
				for (int i=1;i<MAGIC;i++) {
					prod[p[x]][i]*=(0.5+prod[x][i-1]/2);
				}
			}
        } else {
			ld ans = 0;
			for (int i=1;i<MAGIC;i++) {
				ans+=i*(prod[v][i]-prod[v][i-1]);
			}
			printf("%1.9f\n",(double) ans);
		}
	}

	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 500010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int Q,cnt;
double f[maxn][45];
int fa[maxn],son[maxn];
double quick_pow(double x,int p)
{
    double an=1,po=x;
    while(p)
    {
        if(p&1)  an*=po;
        po*=po;
        p>>=1;
    }
    return an;
}
int main()
{
    int bl=30;
    cnt=1;
    for(int i=0;i<=bl;i++)  f[1][i]=1;
    Q=read();
    while(Q--)
    {
        int op=read(),x=read();
        if(op==1)
        {
            cnt++;
            fa[cnt]=x;
            son[x]++;
            double las=f[x][0];
            f[x][0]=quick_pow(0.5,son[x]);
            for(int i=0;i<=bl;i++)  f[cnt][i]=1;
            for(int i=1;i<=bl;i++)
            {
                int u=fa[x];
                if(!u)  break;
                double tmp=f[u][i];
                f[u][i]/=(0.5+0.5*las);
                f[u][i]*=(f[x][i-1]*0.5+0.5);
                las=tmp;
                x=u;
            }
        }
        else{
            double ans=0;
            for(int i=1;i<=bl;i++)  ans+=(double)i*(f[x][i]-f[x][i-1]);
            printf("%.8lf\n",ans);
        }
    }
    return 0;
}