#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vll vector<ll>
#define FOR(i,n) for(ll i=0;i<n;i++)
const ll maxN = 3e5 + 15;
ll n, q;
ll timer = 1;
ll in[maxN];
ll out[maxN];
vll g[maxN];
double seg[4 * maxN];
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 l, ll r, ll pos, ll idx, double val) {
if (l == r && l == idx) {
seg[pos] = val;
return;
}
ll mid = (l + r) / 2;
if (idx <= mid) {
update(l, mid, 2 * pos, idx, val);
}
else {
update(mid + 1, r, 2 * pos + 1, idx, val);
}
seg[pos] = seg[2 * pos] + seg[2 * pos + 1];
}
double query(ll l, ll r, ll pos, ll ql, ll qr) {
if (l >= ql && r <= qr) {
return seg[pos];
}
else if (l > qr || r < ql) {
return 0.0d;
}
ll mid = (l + r) / 2;
return (query(l, mid, 2 * pos, ql, qr) + query(mid + 1, r, 2 * pos + 1, ql, qr));
}
int main()
{
cin >> n;
FOR(i, n - 1) {
ll u, v;
cin >> u >> v;
--u, --v;
g[u].push_back(v);
g[v].push_back(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(1, n, 1, in[x], log2(double(y)));
continue;
}
--x, --y;
double s1 = query(1, n, 1, in[x], out[x]);
double s2 = query(1, n, 1, in[y], out[y]) ;
double as = 1000000000.0d;
if (s1 - s2 >= log2(as)) {
cout << as << endl;
}
else {
cout << pow(2.0, s1 - s2) << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIEZJTyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKE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