You have a root tree containing n vertexes. Let's number the tree vertexes with integers from 1 to n. The tree root is in the vertex 1.

Each vertex (except fot the tree root) v has a direct ancestor pv. Also each vertex v has its integer value sv. 

Your task is to perform following queries:

  * P v u (u ≠ v). If u isn't in subtree of v, you must perform the assignment pv = u. Otherwise you must perform assignment pu = v. Note that after this query the graph continues to be a tree consisting of n vertexes.
  * V v t. Perform assignment sv = t. 



Your task is following. Before starting performing queries and after each query you have to calculate expected value written on the lowest common ancestor of two equiprobably selected vertices i and j. Here lowest common ancestor of i and j is the deepest vertex that lies on the both of the path from the root to vertex i and the path from the root to vertex j. Please note that the vertices i and j can be the same (in this case their lowest common ancestor coincides with them).

Input

The first line of the input contains integer n (2 ≤ n ≤ 5·104) — the number of the tree vertexes. 

The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the description of the tree edges. It is guaranteed that those numbers form a tree.

The third line contains n integers — s1, s2, ... sn (0 ≤ si ≤ 106) — the values written on each vertex of the tree.

The next line contains integer q (1 ≤ q ≤ 5·104) — the number of queries. Each of the following q lines contains the description of the query in the format described in the statement. It is guaranteed that query arguments u and v lie between 1 and n. It is guaranteed that argument t in the queries of type V meets limits 0 ≤ t ≤ 106.

Output

Print q + 1 number — the corresponding expected values. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.

Examples

Input

5
1 2 2 1
1 2 3 4 5
5
P 3 4
P 4 5
V 2 3
P 5 2
P 1 4


Output

1.640000000
1.800000000
2.280000000
2.320000000
2.800000000
1.840000000

Note

Note that in the query P v u if u lies in subtree of v you must perform assignment pu = v. An example of such case is the last query in the sample.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int ch[maxn][2], num[maxn], fa[maxn], rev[maxn], is[maxn], ffa[maxn];
int siz[maxn], siz1[maxn], val[maxn], lz_siz[maxn], lz_pair[maxn];
long long s[maxn], lca_pair[maxn];
void up(int n) {
  int lc = ch[n][0], rc = ch[n][1];
  s[n] = s[lc] + s[rc] + val[n] * (siz[n] - siz1[n] + 0ll);
  num[n] = num[lc] + num[rc] + 1;
}
void re(int n) {
  if (!n) return;
  rev[n] ^= 1;
  swap(ch[n][0], ch[n][1]);
}
void jian_siz(int n, int k) {
  if (!n) return;
  siz[n] += k, siz1[n] += k;
  lz_siz[n] += k;
}
void jian_pair(int n, int k) {
  if (!n) return;
  lca_pair[n] += k * (siz[n] - siz1[n]) * 2;
  lz_pair[n] += k;
}
void down(int n) {
  if (rev[n]) rev[n] = 0, re(ch[n][0]), re(ch[n][1]);
  if (lz_siz[n]) {
    jian_siz(ch[n][0], lz_siz[n]);
    jian_siz(ch[n][1], lz_siz[n]);
    lz_siz[n] = 0;
  }
  if (lz_pair[n]) {
    jian_pair(ch[n][0], lz_pair[n]);
    jian_pair(ch[n][1], lz_pair[n]);
    lz_pair[n] = 0;
  }
}
void rot(int n) {
  int t = fa[n], isr = ch[t][1] == n;
  ch[t][isr] = ch[n][!isr], fa[ch[t][isr]] = t;
  fa[n] = fa[t], fa[t] = n, ch[n][!isr] = t;
  if (is[t])
    is[n] = 1, is[t] = 0;
  else
    ch[fa[n]][ch[fa[n]][1] == t] = n;
  up(t);
}
void P(int n) {
  if (!is[n]) P(fa[n]);
  down(n);
}
void splay(int n) {
  int f, ff;
  P(n);
  while (!is[n]) {
    f = fa[n], ff = fa[f];
    if (is[f])
      rot(n);
    else if ((ch[f][1] == n) == (ch[ff][1] == f))
      rot(f), rot(n);
    else
      rot(n), rot(n);
  }
  up(n);
}
int jud(int u, int v) {
  while (fa[u]) u = fa[u];
  while (fa[v]) v = fa[v];
  return u == v;
}
int get_left_most(int r) {
  while (ch[r][0]) r = ch[r][0];
  P(r);
  return r;
}
void access(int u) {
  int v = 0;
  for (; u; u = fa[v = u]) {
    splay(u), is[ch[u][1]] = 1;
    is[ch[u][1] = v] = 0;
    if (v) {
      v = get_left_most(v);
      siz1[u] = siz[v];
    }
    up(u);
  }
}
void mr(int n) {
  access(n), splay(n);
  rev[n] ^= 1, P(n);
}
void link(int u, int v) {
  access(u), splay(u);
  fa[u] = v;
}
void cut(int u, int v) {
  access(u);
  splay(v);
  fa[v] = 0;
}
void get_lca(int &u, int &v) {
  access(v), v = 0;
  while (1) {
    splay(u);
    if (fa[u] == 0) return;
    is[ch[u][1]] = 1;
    is[v] = 0, ch[u][1] = v;
    if (v) {
      v = get_left_most(v);
      siz1[u] = siz[v];
    }
    up(u), v = u, u = fa[u];
  }
}
long long ans;
vector<int> child[maxn];
void dfs(int n) {
  siz[n] = 1;
  long long tmp = 0;
  for (int i = 0; i < child[n].size(); i++) {
    int v = child[n][i];
    fa[v] = n;
    dfs(v);
    siz[n] += siz[v];
    tmp -= siz[v] * (siz[v] + 0ll);
  }
  tmp += siz[n] * (siz[n] + 0ll);
  lca_pair[n] = tmp;
  ans += tmp * val[n];
  is[n] = 1;
  up(n);
}
void assign(int u, int v) {
  int f = ffa[u];
  access(f), splay(f);
  splay(u);
  siz1[f] = siz[u], up(f);
  jian_siz(f, -siz[u]);
  jian_pair(f, -siz[u]);
  ans -= s[f] * siz[u] * 2;
  cut(f, u);
  link(u, v);
  access(v), splay(v);
  splay(u);
  siz1[v] = 0, up(v);
  jian_siz(v, siz[u]);
  jian_pair(v, siz[u]);
  ans += s[v] * siz[u] * 2;
  ffa[u] = v;
}
char ord[20];
int main() {
  int n, q, i, j, k;
  int u, v;
  scanf("%d", &n);
  for (i = 2; i <= n; i++) scanf("%d", &j), child[j].push_back(i), ffa[i] = j;
  for (i = 1; i <= n; i++) scanf("%d", &val[i]);
  dfs(1);
  printf("%.12lf\n", ans / (n * (n + 0.0)));
  scanf("%d", &q);
  while (q--) {
    scanf("%s%d%d", ord, &u, &v);
    if (ord[0] == 'P') {
      swap(u, v);
      int lca = u, tmp = v;
      get_lca(lca, tmp);
      if (lca - v)
        assign(v, u);
      else
        assign(u, v);
    } else {
      access(u), splay(u);
      ans += (v - val[u]) * lca_pair[u];
      val[u] = v;
      up(u);
    }
    printf("%.12lf\n", ans / (n * (n + 0.0)));
  }
}
