#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], F[100005];
namespace LCT {
int fa[100005], ch[100005][2], siz[100005], xsz[100005];
long long all[100005], ans[100005], sz2[100005], xans[100005];
bool isr(int x) { return ch[fa[x]][0] != x && ch[fa[x]][1] != x; }
bool isc(int x) { return ch[fa[x]][1] == x; }
void upd(int x) {
  siz[x] = siz[ch[x][0]] + siz[ch[x][1]] + xsz[x];
  all[x] = all[ch[x][0]] + all[ch[x][1]] + 1ll * a[x] * xsz[x];
  ans[x] =
      ans[ch[x][0]] + ans[ch[x][1]] + xans[x] +
      a[x] * (1ll * xsz[x] * xsz[x] - sz2[x] + 2ll * xsz[x] * siz[ch[x][1]]) +
      2ll * all[ch[x][0]] * (siz[x] - siz[ch[x][0]]);
}
void rot(int x) {
  int y = fa[x], z = fa[y], c = isc(x);
  !isr(y) && (ch[z][isc(y)] = x);
  fa[ch[y][c] = ch[x][!c]] = y, fa[ch[x][!c] = y] = x, fa[x] = z;
  upd(y);
}
void splay(int x) {
  for (; !isr(x); rot(x))
    if (!isr(fa[x])) rot(isc(fa[x]) == isc(x) ? fa[x] : x);
  upd(x);
}
void access(int x) {
  for (int y = 0; x; x = fa[y = x]) {
    splay(x);
    xsz[x] += siz[ch[x][1]] - siz[y];
    sz2[x] += 1ll * siz[ch[x][1]] * siz[ch[x][1]] - 1ll * siz[y] * siz[y];
    xans[x] += ans[ch[x][1]] - ans[y];
    ch[x][1] = y, upd(x);
  }
}
void prefer(int x) { access(x), splay(x); }
void link(int x, int y) {
  splay(x), prefer(y);
  fa[x] = y, xsz[y] += siz[x], sz2[y] += 1ll * siz[x] * siz[x],
  xans[y] += ans[x], upd(y);
}
void cut(int x) { prefer(x), ch[x][0] = fa[ch[x][0]] = 0, upd(x); }
}  // namespace LCT
using namespace LCT;
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) scanf("%d", &F[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), xsz[i] = 1;
  for (int i = 2; i <= n; i++) link(i, F[i]);
  splay(1), printf("%.9f\n", 1. * ans[1] / n / n);
  scanf("%d", &m);
  char op[2];
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'P') {
      if (prefer(y), splay(x), !isr(y)) swap(x, y);
      cut(x), link(x, F[x] = y);
      printf("%.9f\n", 1. * ans[y] / n / n);
    } else
      prefer(x), a[x] = y, upd(x), printf("%.9f\n", 1. * ans[x] / n / n);
  }
}
