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;
struct rec {
  long long Hsize, Asize, Cople, Val, Ctrib;
  long long Lazy;
} E[200005];
long long Ans;
int fa[200005], lc[200005], rc[200005];
int pa[200005], n;
void Add(int t, long long Ret) {
  if (!t) return;
  E[t].Lazy += Ret;
  E[t].Asize += Ret;
  E[t].Cople += 2 * Ret * E[t].Hsize;
}
void Down(int t) {
  if (!t) return;
  if (E[t].Lazy) {
    Add(lc[t], E[t].Lazy);
    Add(rc[t], E[t].Lazy);
    E[t].Lazy = 0;
  }
}
void Update(int t) {
  if (!t) return;
  E[t].Ctrib = 2 * E[t].Hsize * E[t].Val;
  E[t].Ctrib += E[lc[t]].Ctrib;
  E[t].Ctrib += E[rc[t]].Ctrib;
}
void zig(int x) {
  int y = fa[x], z = fa[y];
  fa[x] = z;
  fa[y] = x;
  fa[rc[x]] = y;
  lc[y] = rc[x];
  rc[x] = y;
  if (lc[z] == y) lc[z] = x;
  if (rc[z] == y) rc[z] = x;
  Update(y);
}
void zag(int x) {
  int y = fa[x], z = fa[y];
  fa[x] = z;
  fa[y] = x;
  fa[lc[x]] = y;
  rc[y] = lc[x];
  lc[x] = y;
  if (lc[z] == y) lc[z] = x;
  if (rc[z] == y) rc[z] = x;
  Update(y);
}
int stk[200005];
bool top(int x) { return !fa[x] || (lc[fa[x]] != x && rc[fa[x]] != x); }
void Splay(int x) {
  if (!x) return;
  int y, z = 0;
  for (y = x; !top(y); y = fa[y]) stk[++z] = y;
  stk[++z] = y;
  for (; z; z--) Down(stk[z]);
  while (!top(x)) {
    y = fa[x], z = fa[y];
    if (!top(y)) {
      if (lc[z] == y) {
        if (lc[y] == x)
          zig(y), zig(x);
        else
          zag(x), zig(x);
      } else {
        if (rc[y] == x)
          zag(y), zag(x);
        else
          zig(x), zag(x);
      }
    } else if (lc[y] == x)
      zig(x);
    else
      zag(x);
  }
  Update(x);
}
long long Calc(long long A, long long B) { return 2 * B * (A - B); }
int Find_L(int x) {
  for (; x && lc[x]; x = lc[x])
    ;
  Splay(x);
  return x;
}
int Find_R(int x) {
  for (; x && rc[x]; x = rc[x])
    ;
  Splay(x);
  return x;
}
int access(int x) {
  int y = 0, p;
  for (; x; y = x, x = fa[x]) {
    Splay(x);
    p = rc[x];
    rc[x] = 0;
    p = Find_L(p);
    E[x].Hsize += E[p].Asize;
    p = Find_L(y);
    rc[x] = p;
    E[x].Hsize -= E[p].Asize;
    Update(x);
  }
  return y;
}
void work(int x, long long Ret) {
  Splay(x);
  if (Ret > 0) {
    Ans += E[x].Val * Calc(E[x].Asize + Ret, Ret);
    E[x].Cople += Calc(E[x].Asize + Ret, Ret);
  } else {
    Ans -= E[x].Val * Calc(E[x].Asize, -Ret);
    E[x].Cople -= Calc(E[x].Asize, -Ret);
  }
  E[x].Asize += Ret;
  E[x].Hsize += Ret;
  E[x].Ctrib += Ret * E[x].Val;
  Ans += E[lc[x]].Ctrib * Ret;
  Add(lc[x], Ret);
}
void Link(int x, int y) {
  Splay(x);
  fa[x] = y;
  access(y);
  work(y, E[x].Asize);
}
void Cut(int x, int y) {
  access(y);
  Splay(x);
  fa[x] = 0;
  work(y, -E[x].Asize);
}
void Move(int x, int y) {
  if (x == y) return;
  access(x);
  int lca = access(y);
  if (lca == x) swap(x, y);
  Cut(x, pa[x]);
  Link(x, y);
  pa[x] = y;
}
void Modify(int x, long long Ret) {
  access(x);
  Splay(x);
  Ans -= E[x].Cople * E[x].Val;
  E[x].Val = Ret;
  Ans += E[x].Cople * E[x].Val;
  Update(x);
}
char ch[5];
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) scanf("%d", &pa[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &E[i].Val);
    Ans += E[i].Val;
    E[i].Hsize = 1;
    E[i].Asize = 1;
    E[i].Cople = 1;
    E[i].Ctrib = E[i].Val;
  }
  for (int i = 2; i <= n; i++) Link(i, pa[i]);
  printf("%.12lf\n", Ans / (1.0 * n * n));
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    char ch[3];
    int x, y;
    scanf("%s%d%d", ch, &x, &y);
    if (ch[0] == 'P') Move(x, y);
    if (ch[0] == 'V') Modify(x, y);
    printf("%.12lf\n", Ans / (1.0 * n * n));
  }
}
