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 = 2e5 + 7;
int a[MAXN], n, m;
long long n2;
namespace fastIO {
char buf[(1 << 20)], *p1 = buf + (1 << 20), *pend = (1 << 20) + buf;
inline char nc() {
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, (1 << 20), stdin);
  }
  return *p1++;
}
inline int read() {
  int x = 0;
  char s = nc();
  for (; !isdigit(s); s = nc())
    ;
  for (; isdigit(s); s = nc()) x = (x << 1) + (x << 3) + s - '0';
  return x;
}
}  // namespace fastIO
using namespace fastIO;
char s[20];
namespace LCT {
int ch[MAXN][2], fa[MAXN], tag[MAXN], st[MAXN];
long long sum[MAXN], ans[MAXN], sa[MAXN], sx1[MAXN], sx2[MAXN], ax[MAXN];
inline bool nroot(int x) { return ch[fa[x]][0] == x || ch[fa[x]][1] == x; }
inline void outmes(int x) {
  printf("Node :%d L: %d R: %d\n", x, (ch[x][0]), (ch[x][1]));
  printf("sum :%lld ans: %lld sa: %lld sx1: %lld sx2: %lld ax: %lld\n", sum[x],
         ans[x], sa[x], sx1[x], sx2[x], ax[x]);
  puts("\n");
}
inline void pushup(int x) {
  sum[x] = sum[(ch[x][0])] + sum[(ch[x][1])] + sx1[x] + 1;
  sa[x] = sa[(ch[x][0])] + sa[(ch[x][1])] + (sx1[x] + 1) * a[x];
  ans[x] = ans[(ch[x][0])] + ans[(ch[x][1])] + ax[x] +
           a[x] * ((sx1[x] + 1) * (sx1[x] + 1) - sx2[x]) +
           2 * a[x] * (sx1[x] + 1) * sum[(ch[x][1])] +
           2 * sa[(ch[x][0])] * (sum[(ch[x][1])] + sx1[x] + 1);
}
inline void rotate(int x) {
  int y = (fa[x]);
  int z = fa[y];
  int k = ch[y][1] == x;
  int w = ch[x][!k];
  if (nroot(y)) {
    ch[z][ch[z][1] == y] = x;
  }
  ch[x][!k] = y;
  ch[y][k] = w;
  if (w) fa[w] = y;
  fa[y] = x;
  fa[x] = z;
  pushup(y);
}
inline void pushR(int x) {
  (ch[x][0]) ^= (ch[x][1]) ^= (ch[x][0]) ^= (ch[x][1]);
  tag[x] ^= 1;
}
inline void pushdown(int x) {
  if (tag[x]) {
    if ((ch[x][0])) pushR((ch[x][0]));
    if ((ch[x][1])) pushR((ch[x][1]));
    tag[x] = 0;
  }
}
inline void outtree() {
  for (int i = 1; i <= n; ++i) {
    printf("%d %d %d %d\n", i, fa[i], ch[i][0], ch[i][1]);
  }
  return;
}
inline void splay(int x) {
  int z = 0, y = x;
  st[++z] = y;
  while (nroot(y)) {
    st[++z] = fa[y];
    y = fa[y];
  }
  while (z) pushdown(st[z]), z--;
  while (nroot(x)) {
    y = (fa[x]);
    z = fa[y];
    if (nroot(y)) {
      rotate((ch[y][1] == x) ^ (ch[z][1] == y) ? x : y);
    }
    rotate(x);
  }
  pushup(x);
}
inline void add(int x, int y, int t) {
  sx1[x] += t * sum[y];
  sx2[x] += t * sum[y] * sum[y];
  ax[x] += ans[y] * t;
}
inline void access(int x) {
  for (int y = 0; x; x = (fa[x])) {
    splay(x);
    add(x, (ch[x][1]), 1);
    add(x, y, -1);
    (ch[x][1]) = y;
    pushup(x);
    y = x;
  }
}
inline void makeroot(int x) {
  access(x);
  splay(x);
  pushR(x);
}
inline void split(int x, int y) {
  makeroot(x);
  access(y);
  splay(y);
}
inline void link(int x, int y) {
  access(x);
  splay(x);
  splay(y);
  fa[y] = x;
  add(x, y, 1);
  pushup(x);
  return;
}
inline void cut(int x, int y) {
  access(x);
  splay(x);
  access(y);
  splay(y);
  ch[y][0] = 0;
  fa[x] = 0;
  pushup(y);
  return;
}
inline int chk(int x, int y) {
  access(y);
  splay(y);
  splay(x);
  return nroot(y);
}
}  // namespace LCT
using namespace LCT;
inline void outans() {
  makeroot(1);
  printf("%lf\n", ans[1] / (1.0 * n2));
  return;
}
int f[MAXN];
inline void init() {
  n2 = 1ll * n * n;
  pushup(1);
  for (int i = 2; i <= n; ++i) {
    pushup(i);
    link(f[i], i);
  }
  outans();
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) scanf("%d", &f[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  init();
  scanf("%d", &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%s", s);
    scanf("%d%d", &x, &y);
    if (s[0] == 'P') {
      if (f[x] == y || f[y] == x) {
        outans();
        continue;
      }
      if (chk(x, y)) swap(x, y);
      cut(f[x], x);
      f[x] = y;
      link(y, x);
    } else {
      access(x);
      splay(x);
      a[x] = y;
      pushup(x);
    }
    outans();
  }
  return 0;
}
