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 he[500050], ne[500050 << 2], to[500050 << 2], tot, alfa[500050];
int n, m;
inline void addedge(int x, int y) {
  to[++tot] = y;
  ne[tot] = he[x];
  he[x] = tot;
}
int fa[500050], ch[500050][2];
long long sz[500050], a[500050], v1[500050], s1[500050], v2[500050], v3[500050],
    tag[500050], ans;
inline void dfs(int g) {
  sz[g] = 1;
  for (int i = he[g]; i; i = ne[i]) {
    dfs(to[i]);
    sz[g] += sz[to[i]];
    v3[g] -= 1ll * sz[to[i]] * sz[to[i]];
  }
  v1[g] = s1[g] = 0;
  v2[g] = sz[g];
  v3[g] += 1ll * sz[g] * (sz[g]);
  ans += v3[g] * a[g];
}
inline int Get(int x) { return ch[fa[x]][1] == x; }
inline int nroot(int x) { return ch[fa[x]][0] == x || ch[fa[x]][1] == x; }
inline void push1(int x, long long v) {
  if (!x) return;
  tag[x] += v;
  if (sz[x] == v2[x]) {
    v1[x] = 0;
    v3[x] += 2 * v * sz[x] + v * v;
    v2[x] += v;
    sz[x] += v;
  } else {
    v3[x] += 2 * v * v2[x];
    sz[x] += v;
  }
}
inline void down(int x) {
  if (!tag[x]) return;
  if (ch[x][0]) push1(ch[x][0], tag[x]);
  if (ch[x][1]) push1(ch[x][1], tag[x]);
  tag[x] = 0;
  return;
}
inline void upd(int x) { s1[x] = s1[ch[x][0]] + s1[ch[x][1]] + v1[x]; }
inline void renew(int x, int y) {
  if (!x) return;
  if (y) {
    v2[x] = sz[x] - sz[y];
    v1[x] = v2[x] * a[x];
  } else {
    v2[x] = sz[x];
    v1[x] = 0;
  }
  upd(x);
}
inline void pushall(int x) {
  if (nroot(x)) pushall(fa[x]);
  down(x);
}
inline void rotate(int x) {
  int y = fa[x], z = fa[y], p = Get(x), w = ch[x][p ^ 1];
  if (w) fa[w] = y;
  ch[y][p] = w;
  if (nroot(y)) ch[z][Get(y)] = x;
  fa[x] = z;
  fa[y] = x;
  ch[x][p ^ 1] = y;
  upd(y);
  upd(x);
}
inline void splay(int x) {
  pushall(x);
  while (nroot(x)) {
    int y = fa[x];
    if (nroot(y)) rotate(Get(x) == Get(y) ? y : x);
    rotate(x);
  }
}
inline int findroot(int x) {
  splay(x);
  while (ch[x][0]) down(x), x = ch[x][0];
  splay(x);
  return x;
}
inline void access(int x) {
  for (int y = 0; x; x = fa[y = x]) {
    splay(x);
    ch[x][1] = y;
    renew(x, y);
    x = findroot(x);
  }
}
inline void cut(int x) {
  access(x);
  splay(x);
  ans -= 2 * sz[x] * s1[x];
  int f = alfa[x];
  fa[ch[x][0]] = 0;
  ch[x][0] = 0;
  access(f);
  splay(f);
  v3[f] -= 2 * (-sz[x]) * sz[x] + sz[x] * sz[x];
  push1(f, -sz[x]);
}
inline void link(int x, int y) {
  access(y);
  splay(y);
  push1(y, sz[x]);
  v3[y] -= sz[x] * sz[x];
  fa[x] = y;
  access(x);
  splay(x);
  ans += 2 * s1[x] * sz[x];
}
inline void change(int x, int y) {
  cut(x);
  link(x, y);
}
inline void addval(int x, long long v) {
  access(x);
  splay(x);
  ans += v * v3[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i)
    scanf("%d", &alfa[i]), fa[i] = alfa[i], addedge(fa[i], i);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  dfs(1);
  const double P = 1.0l / n / n;
  printf("%.10lf\n", P * ans);
  scanf("%d", &m);
  char s[3];
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%s%d%d", s, &x, &y);
    if (s[0] == 'P') {
      access(y);
      if (findroot(y) == findroot(x))
        change(y, x), alfa[y] = x;
      else
        change(x, y), alfa[x] = y;
    } else {
      y -= a[x];
      addval(x, y);
      a[x] += y;
    }
    printf("%.10lf\n", P * ans);
  }
  return 0;
}
