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;
int n, m, tot, tp, q[50005], fa[50005], c[50005][2], fst[50005], pnt[50005],
    nxt[50005];
long long ans;
struct node {
  int dsz, sz, icr, val;
  long long w, sum;
} P[50005];
void add(int x, int y) {
  pnt[++tot] = y;
  nxt[tot] = fst[x];
  fst[x] = tot;
}
void maintain(int x) {
  node &o = P[x], &l = P[c[x][0]], &r = P[c[x][1]];
  o.sz = o.dsz + l.sz + r.sz;
  o.sum = (long long)o.dsz * o.val + l.sum + r.sum;
}
void mdy(int x, int y) {
  node &o = P[x];
  o.icr += y;
  o.w += (long long)y * o.dsz;
}
void pushdn(int x) {
  if (P[x].icr) {
    mdy(c[x][0], P[x].icr);
    mdy(c[x][1], P[x].icr);
    P[x].icr = 0;
  }
}
void rot(int x) {
  int y = fa[x], z = fa[y], l = (c[y][1] == x), r = l ^ 1;
  if (!(c[fa[y]][0] != y && c[fa[y]][1] != y)) c[z][c[z][1] == y] = x;
  fa[x] = z;
  fa[y] = x;
  fa[c[x][r]] = y;
  c[y][l] = c[x][r];
  c[x][r] = y;
  maintain(y);
}
void splay(int x) {
  int i, y, z;
  q[tp = 1] = x;
  for (i = x; !(c[fa[i]][0] != i && c[fa[i]][1] != i); i = fa[i])
    q[++tp] = fa[i];
  while (tp) pushdn(q[tp--]);
  for (; !(c[fa[x]][0] != x && c[fa[x]][1] != x); rot(x)) {
    y = fa[x];
    z = fa[y];
    if (!(c[fa[y]][0] != y && c[fa[y]][1] != y))
      rot((c[z][0] == y ^ c[y][0] == x) ? x : y);
  }
  maintain(x);
}
void acss(int x) {
  int y = 0;
  for (; x; y = x, x = fa[x]) {
    splay(x);
    P[x].dsz += P[c[x][1]].sz;
    c[x][1] = y;
    P[x].dsz -= P[y].sz;
    maintain(x);
  }
}
void dfs(int x) {
  int i, y;
  node &o = P[x];
  o.w = o.dsz = 1;
  for (i = fst[x]; i; i = nxt[i]) {
    y = pnt[i];
    dfs(y);
    o.w += (long long)o.dsz * P[y].dsz << 1;
    o.dsz += P[y].dsz;
  }
  ans += o.val * o.w;
  maintain(x);
}
int main() {
  scanf("%d", &n);
  int i, x, y, z;
  for (i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    add(fa[i], i);
  }
  for (i = 1; i <= n; i++) scanf("%d", &P[i].val);
  dfs(1);
  printf("%.15f\n", (double)ans / n / n);
  scanf("%d", &m);
  char cr;
  while (m--) {
    cr = getchar();
    while (cr < 'A' || cr > 'Z') cr = getchar();
    scanf("%d%d", &x, &y);
    if (cr == 'P') {
      acss(y);
      splay(x);
      for (z = x; !(c[fa[z]][0] != z && c[fa[z]][1] != z); z = c[z][0])
        ;
      if (fa[z])
        acss(x);
      else
        swap(x, y);
      if (!c[x][0])
        z = fa[x];
      else
        for (z = c[x][0]; c[z][1]; z = c[z][1])
          ;
      if (z != y) {
        acss(z);
        splay(z);
        splay(x);
        P[z].dsz -= P[x].sz;
        mdy(z, -(P[x].sz << 1));
        maintain(z);
        ans -= P[z].sum * P[x].sz << 1;
        acss(y);
        splay(y);
        ans += P[y].sum * P[x].sz << 1;
        mdy(y, P[x].sz << 1);
        P[y].dsz += P[x].sz;
        maintain(y);
        fa[x] = y;
      }
    } else {
      splay(x);
      ans += (y - P[x].val) * P[x].w;
      P[x].val = y;
    }
    printf("%.15f\n", (double)ans / n / n);
  }
  return 0;
}
