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 = 2e6 + 10;
long long siz01[maxn], siz02[maxn], ans[maxn], ans0[maxn], siz11[maxn],
    sum[maxn];
int ch[maxn][2], r[maxn], fa[maxn], n;
int F[maxn];
long long a[maxn];
char c[3];
bool nr(int x) { return ch[fa[x]][0] == x || ch[fa[x]][1] == x; }
void ud(int x) {
  siz11[x] = siz11[ch[x][0]] + siz11[ch[x][1]] + siz01[x];
  sum[x] = sum[ch[x][0]] + sum[ch[x][1]] + siz01[x] * a[x];
  ans[x] = ans[ch[x][0]] + ans[ch[x][1]] + ans0[x];
  ans[x] += (siz01[x] * siz01[x] - siz02[x]) * a[x];
  ans[x] += (2ll * siz11[ch[x][1]] * siz01[x]) * a[x];
  ans[x] += (2ll * sum[ch[x][0]] * (siz11[x] - siz11[ch[x][0]]));
}
int st[maxn], z;
void ro(int x, int w) {
  int f = fa[x], ff = fa[f];
  if (nr(f)) {
    if (ch[ff][0] == f)
      ch[ff][0] = x;
    else
      ch[ff][1] = x;
  }
  if (ch[x][w]) fa[ch[x][w]] = f;
  ch[f][w ^ 1] = ch[x][w];
  ch[x][w] = f;
  fa[f] = x;
  fa[x] = ff;
  ud(f);
  ud(x);
}
void splay(int x) {
  while (nr(x)) {
    int f = fa[x], ff = fa[f];
    if (!nr(f)) {
      if (ch[f][0] == x)
        ro(x, 1);
      else
        ro(x, 0);
    } else {
      if (ch[ff][0] == f) {
        if (ch[f][0] == x)
          ro(f, 1), ro(x, 1);
        else
          ro(x, 0), ro(x, 1);
      } else {
        if (ch[f][1] == x)
          ro(f, 0), ro(x, 0);
        else
          ro(x, 1), ro(x, 0);
      }
    }
  }
}
void access(int x) {
  for (int y = 0; x; x = fa[y = x]) {
    splay(x);
    siz01[x] += siz11[ch[x][1]];
    siz02[x] += siz11[ch[x][1]] * siz11[ch[x][1]];
    ans0[x] += ans[ch[x][1]];
    ch[x][1] = y;
    siz01[x] -= siz11[y];
    siz02[x] -= siz11[y] * siz11[y];
    ans0[x] -= ans[y];
    ud(x);
  }
}
void mr(int x) {
  access(x);
  splay(x);
}
void link(int x, int y) {
  mr(x);
  mr(y);
  siz01[y] += siz11[x];
  siz02[y] += siz11[x] * siz11[x];
  ans0[y] += ans[x];
  fa[x] = y;
  ud(y);
}
bool check(int x, int y) {
  mr(y);
  splay(x);
  if (!nr(y)) return 0;
  return 1;
}
void print(long long x) {
  double ans = (double)x / (double)n / (double)n;
  printf("%.12lf\n", ans);
}
void cut(int x, int y) {
  mr(y);
  splay(x);
  siz01[y] -= siz11[x];
  siz02[y] -= siz11[x] * siz11[x];
  ans0[y] -= ans[x];
  fa[x] = 0;
  ud(y);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) scanf("%d", &F[i]);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; ++i) siz11[i] = siz01[i] = 1, ans[i] = sum[i] = a[i];
  for (int i = 2; i <= n; ++i) link(i, F[i]);
  int q;
  scanf("%d", &q);
  mr(1);
  print(ans[1]);
  while (q--) {
    scanf("%s", c + 1);
    if (c[1] == 'V') {
      int x;
      long long y;
      scanf("%d%lld", &x, &y);
      mr(x);
      a[x] = y;
      ud(x);
      print(ans[x]);
    } else {
      int x, y;
      scanf("%d%d", &x, &y);
      if (check(x, y)) swap(x, y);
      cut(x, F[x]);
      F[x] = y;
      link(x, F[x]);
      mr(1);
      print(ans[1]);
    }
  }
  return 0;
}
