#include <bits/stdc++.h>
using namespace std;
#include <string.h>
#include <iomanip>
#include <map>
#define MEM(var, val) memset(var, (val), sizeof(var))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define nitro \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
//*max_element(a.begin(), a.end())
vll t,a;
vector<vll> adj;
void build(ll i, ll l,ll r)
{
if(l==r)
{
t[i]=a[l];
return;
}
ll mid=(l+r)/2;
build(2*i,l,mid);
build(2*i+1,mid+1,r);
t[i]=t[2*i]*t[2*i+1];
return;
}
void update(ll i,ll l,ll r,ll pos,ll val)
{
if(l==r)
{t[i]=val;
return ;
}
ll mid=(l+r)/2;
if(pos>mid)
update(2*i+1,mid+1,r,pos,val);
else
update(2*i,l,mid,pos,val);
t[i]=t[2*i]*t[2*i+1];
return ;
}
ll getval(ll i,ll l,ll r,ll p1,ll p2)
{
if(p1==l&&p2==r)
return t[i];
ll mid=(l+r)/2;
if(p1>mid)
return getval(2*i+1,mid+1,r,p1,p2);
else if(p2<=mid)
return getval(2*i,l,mid,p1,p2);
else return getval(2*i,l,mid,p1,mid)*getval(2*i+1,mid+1,r,mid+1,p2);
}
vll enter,leave;
ll timer=1;
void dfs(ll v, ll p)
{
enter[v]=timer;
for(int u : adj[v])
{
if(u!=p)
{
timer++;
dfs(u,v);
}
}
leave[v]=timer;
return ;
}
int main()
{
ll n;
ll q;
cin>>n;
a.resize(n+1,1);
adj.resize(n+1);
for(int i=0;i<n-1;i++)
{
ll a,b;
cin>>a>>b;
adj[a].pb(b);
adj[b].pb(a);
}
enter.resize(n+1);
leave.resize(n+1);
dfs(1,0);
t.resize(4*n+1,0);
build(1,1,n);
// for(int i=1;i<=4*n;i++)
// cout<<t[i]<<" ";
cin>>q;
ll t1,x,y;
for(int i=0;i<q;i++)
{
cin>>t1>>x>>y;
if(t1==1)
update(1,1,n,enter[x],y);
else {
ll p1,p2;
p1=enter[x];
p2=leave[x];
long double ans=getval(1,1,n,p1,p2)+0.0;
p1=enter[y];
p2=leave[y];
ans=(ans+0.0)/(getval(1,1,n,p1,p2)+0.0);
cout<<std::fixed;
ans=ans+0.0;
if(ans>1e9)
cout<<"1000000000\n";
else cout<<setprecision(10)<<ans<<"\n";
}
}
// for(int i=1;i<=4*n;i++)
// cout<<t[i]<<" ";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPGlvbWFuaXA+ICAgCiNpbmNsdWRlIDxtYXA+CiNkZWZpbmUgTUVNKHZhciwgdmFsKSBtZW1zZXQodmFyLCAodmFsKSwgc2l6ZW9mKHZhcikpCiNkZWZpbmUgTUFYKGEsIGIpICgoYSkgPiAoYikgPyAoYSkgOiAoYikpCiNkZWZpbmUgTUlOKGEsIGIpICgoYSkgPCAoYikgPyAoYSkgOiAoYikpCiNkZWZpbmUgbml0cm8gICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IFwKICAgIGNpbi50aWUoTlVMTCk7ICAgICAgICAgICAgICAgICAgICBcCiAgICBjb3V0LnRpZShOVUxMKTsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgdW5zaWduZWQgbG9uZyBsb25nIHVsbDsKdHlwZWRlZiBwYWlyPGxsLCBsbD4gcGxsOwp0eXBlZGVmIHZlY3RvcjxsbD4gdmxsOwojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAovLyptYXhfZWxlbWVudChhLmJlZ2luKCksIGEuZW5kKCkpCnZsbC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1lcjsKICAgIGZvcihpbnQgdSA6IGFkalt2XSkKICAgIHsKICAgICAgICBpZih1IT1wKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB0aW1lcisrOwogICAgICAgICAgICAgICAgZGZzKHUsdik7CiAgICAgICAgICAgIH0KICAgIH0KICAgIGxlYXZlW3ZdPXRpbWVyOwogICAgcmV0dXJuIDsKfQppbnQgbWFpbigpCnsKICAgIGxsIG47CiAgICBsbCBxOwogICAgY2luPj5uOwogICAgYS5yZXNpemUobisxLDEpOwogICBhZGoucmVzaXplKG4rMSk7CiAgIGZvcihpbnQgaT0wO2k8bi0xO2krKykKICAgewogICAgICAgbGwgYSxiOwogICAgICAgY2luPj5hPj5iOwogICAgICAgYWRqW2FdLnBiKGIpOwogICAgICAgYWRqW2JdLnBiKGEpOwogICB9CiAgIGVudGVyLnJlc2l6ZShuKzEpOwogICBsZWF2ZS5yZXNpemUobisxKTsKICAgIGRmcygxLDApOwogICAgdC5yZXNpemUoNCpuKzEsMCk7CiAgICBidWlsZCgxLDEsbik7CiAgICAvLyBmb3IoaW50IGk9MTtpPD00Km47aSsrKQogICAgLy8gY291dDw8dFtpXTw8IiAiOwogICAKICAgIGNpbj4+cTsKICAgIGxsIHQxLHgseTsKICAgIGZvcihpbnQgaT0wO2k8cTtpKyspCiAgICB7CiAgICAgICAgY2luPj50MT4+eD4+eTsKICAgICAgICBpZih0MT09MSkKICAgICAgICB1cGRhdGUoMSwxLG4sZW50ZXJbeF0seSk7CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGxsIHAxLHAyOwogICAgICAgICAgICBwMT1lbnRlclt4XTsKICAgICAgICAgICAgcDI9bGVhdmVbeF07CiAgICAgICAgICAgIGxvbmcgIGRvdWJsZSBhbnM9Z2V0dmFsKDEsMSxuLHAxLHAyKSswLjA7CiAgICAgICAgICAgICAKICAgICAgICAgICAgcDE9ZW50ZXJbeV07CiAgICAgICAgICAgIHAyPWxlYXZlW3ldOwogICAgICAgICAgICBhbnM9KGFucyswLjApLyhnZXR2YWwoMSwxLG4scDEscDIpKzAuMCk7CiAgICAgICAgICAgICBjb3V0PDxzdGQ6OmZpeGVkOwogICAgICAgICAgICBhbnM9YW5zKzAuMDsKICAgICAgICAgICAgaWYoYW5zPjFlOSkKICAgICAgICAgICAgY291dDw8IjEwMDAwMDAwMDBcbiI7CiAgICAgICAgICAgIGVsc2UgY291dDw8c2V0cHJlY2lzaW9uKDEwKTw8YW5zPDwiXG4iOwogICAgICAgIH0gICAgICAgCiAgICB9CiAgICAvLyBmb3IoaW50IGk9MTtpPD00Km47aSsrKQogICAgLy8gY291dDw8dFtpXTw8IiAiOwp9