#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 3e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;
int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left
ll powerM(ll x, ll y, ll M = mod) { // default argument
ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}
ll power(ll x, ll y) {
ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}
// WHY THE HELL IS IT NOT WORKING USING FENWICK TREE
ll timer = 1, n, q;
ll in[maxN];
ll out[maxN];
vll g[maxN];
double bit[2 * maxN]; // this is 1 indexed
void dfs(ll node, ll p) {
in[node] = timer;
for (auto& u : g[node]) {
if (u == p)
continue;
++timer;
dfs(u, node);
}
out[node] = timer;
}
void update(ll idx, double val) {
double prev = bit[idx];
double change = val - prev;
while (idx <= n) {
bit[idx] += change;
idx += (idx & (-idx));
}
}
double sum(ll idx) {
double s = 0.0d;
while (idx > 0) {
s += bit[idx];
idx -= (idx & (-idx));
}
return s;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in4.txt", "r", stdin);
freopen("out1.txt", "w", stdout);
#endif
FIO
cin >> n;
FOR(i, n - 1) {
ll u, v;
cin >> u >> v;
--u, --v;
g[u].pb(v);
g[v].pb(u);
}
dfs(0, -1);
cout << fixed << setprecision(12);
cin >> q;
while (q--) {
ll t, x, y;
cin >> t >> x >> y;
if (t == 1) {
--x;
update(in[x], log2(y * 1.0d));
continue;
}
--x, --y;
double s1 = sum(out[x]) - sum(in[x] - 1);
double s2 = sum(out[y]) - sum(in[y] - 1);
double as = 1000000000.0d;
if (s1 - s2 >= log2(1000000000.0d)) {
cout << as << endl;
}
else {
cout << pow(2.0, s1 - s2) << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIG5hbWVzcGFjZSBzdGQ6OmNocm9ubzsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSB1bGwgdW5zaWduZWQgbG9uZyBsb25nCiNkZWZpbmUgRklPIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoTlVMTCk7CiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZWIgZW1wbGFjZV9iYWNrCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKI2RlZmluZSB2dCB2ZWN0b3IKI2RlZmluZSB2bGwgdnQ8bGw+CiNkZWZpbmUgcGxsIHBhaXI8bGwsbGw+CiNkZWZpbmUgdnBsbCB2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