Problem: There are n cities in Cyberland, numbered from 1 to n, connected by m bidirectional roads. The j-th road connects city aj and bj.

For tourists, souvenirs are sold in every city of Cyberland. In particular, city i sell it at a price of wi.

Now there are q queries for you to handle. There are two types of queries:

  * "C a w": The price in city a is changed to w.
  * "A a b": Now a tourist will travel from city a to b. He will choose a route, he also doesn't want to visit a city twice. He will buy souvenirs at the city where the souvenirs are the cheapest (possibly exactly at city a or b). You should output the minimum possible price that he can buy the souvenirs during his travel.



More formally, we can define routes as follow:

  * A route is a sequence of cities [x1, x2, ..., xk], where k is a certain positive integer.
  * For any 1 ≤ i < j ≤ k, xi ≠ xj.
  * For any 1 ≤ i < k, there is a road connecting xi and xi + 1.
  * The minimum price of the route is min(wx1, wx2, ..., wxk).
  * The required answer is the minimum value of the minimum prices of all valid routes from a to b.

Input

The first line of input contains three integers n, m, q (1 ≤ n, m, q ≤ 105), separated by a single space.

Next n lines contain integers wi (1 ≤ wi ≤ 109).

Next m lines contain pairs of space-separated integers aj and bj (1 ≤ aj, bj ≤ n, aj ≠ bj).

It is guaranteed that there is at most one road connecting the same pair of cities. There is always at least one valid route between any two cities.

Next q lines each describe a query. The format is "C a w" or "A a b" (1 ≤ a, b ≤ n, 1 ≤ w ≤ 109).

Output

For each query of type "A", output the corresponding answer.

Examples

Input

3 3 3
1
2
3
1 2
2 3
1 3
A 2 3
C 1 5
A 2 3


Output

1
2


Input

7 9 4
1
2
3
4
5
6
7
1 2
2 5
1 5
2 3
3 4
2 4
5 6
6 7
5 7
A 2 3
A 6 4
A 6 7
A 3 3


Output

2
1
5
3

Note

For the second sample, an optimal routes are:

From 2 to 3 it is [2, 3].

From 6 to 4 it is [6, 5, 1, 2, 4].

From 6 to 7 it is [6, 5, 7].

From 3 to 3 it is [3].

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
multiset<int> F[400010];
int n, m, q, op, len = 0, lena = 0, lenb = 0;
int val[400010], lasta[400010], lastb[400010], sta[400010], dfn[400010],
    low[400010];
int top[400010], dep[400010], size[400010], fa[400010], son[400010], id[400010];
struct node1 {
  int x, y, next;
} a[800010], b[800010];
struct node2 {
  int l, r, lc, rc, mi;
} tr[800010];
void insa(int x, int y) {
  a[++lena] = (node1){x, y, lasta[x]};
  lasta[x] = lena;
}
void insb(int x, int y) {
  b[++lenb] = (node1){x, y, lastb[x]};
  lastb[x] = lenb;
}
int TOP = 0, cnt = 0;
void tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  sta[++TOP] = x;
  for (int i = lastb[x]; i; i = b[i].next) {
    int y = b[i].y;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        op++, insa(op, x), insa(x, op);
        int tmp;
        do {
          tmp = sta[TOP--];
          insa(op, tmp), insa(tmp, op);
        } while (tmp != y);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
void dfs1(int x) {
  size[x] = 1;
  for (int i = lasta[x]; i; i = a[i].next) {
    int y = a[i].y;
    if (y == fa[x]) continue;
    dep[y] = dep[x] + 1;
    fa[y] = x;
    if (x > n) F[x].insert(val[y]);
    dfs1(y);
    size[x] += size[y];
    if (size[y] > size[son[x]]) son[x] = y;
  }
}
int cntt = 0;
void dfs2(int x, int tp) {
  id[x] = ++cntt;
  top[x] = tp;
  if (son[x]) dfs2(son[x], tp);
  for (int i = lasta[x]; i; i = a[i].next) {
    int y = a[i].y;
    if (y == fa[x] || y == son[x]) continue;
    dfs2(y, y);
  }
}
void build(int l, int r) {
  int now = ++len;
  tr[now] = (node2){l, r, -1, -1, 2147483647};
  if (l < r) {
    int mid = (l + r) >> 1;
    tr[now].lc = len + 1;
    build(l, mid);
    tr[now].rc = len + 1;
    build(mid + 1, r);
  }
}
void change(int now, int x, int d) {
  if (tr[now].l == tr[now].r) {
    tr[now].mi = d;
    return;
  }
  int lc = tr[now].lc, rc = tr[now].rc, mid = (tr[now].l + tr[now].r) >> 1;
  if (x <= mid)
    change(lc, x, d);
  else
    change(rc, x, d);
  tr[now].mi = min(tr[lc].mi, tr[rc].mi);
}
int findmin(int now, int l, int r) {
  if (tr[now].l == l && tr[now].r == r) return tr[now].mi;
  int lc = tr[now].lc, rc = tr[now].rc, mid = (tr[now].l + tr[now].r) >> 1;
  if (r <= mid)
    return findmin(lc, l, r);
  else if (l > mid)
    return findmin(rc, l, r);
  else
    return min(findmin(lc, l, mid), findmin(rc, mid + 1, r));
}
int solve(int x, int y) {
  int tx = top[x], ty = top[y];
  int mi = 2147483647;
  while (tx != ty) {
    if (dep[tx] > dep[ty]) swap(x, y), swap(tx, ty);
    mi = min(mi, findmin(1, id[ty], id[y]));
    y = fa[ty];
    ty = top[y];
  }
  if (dep[x] > dep[y]) swap(x, y);
  mi = min(mi, findmin(1, id[x], id[y]));
  if (x > n) mi = min(mi, val[fa[x]]);
  return mi;
}
int main() {
  char s[10];
  int x, y;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    insb(x, y), insb(y, x);
  }
  op = n;
  tarjan(1);
  dfs1(1);
  dfs2(1, 1);
  build(1, op);
  for (int i = 1; i <= n; i++) change(1, id[i], val[i]);
  for (int i = n + 1; i <= op; i++) change(1, id[i], *F[i].begin());
  for (int i = 1; i <= q; i++) {
    scanf("%s %d %d", s + 1, &x, &y);
    if (s[1] == 'C') {
      if (fa[x])
        F[fa[x]].erase(F[fa[x]].lower_bound(val[x])), F[fa[x]].insert(y),
            change(1, id[fa[x]], *F[fa[x]].begin());
      val[x] = y, change(1, id[x], val[x]);
    } else {
      printf("%d\n", solve(x, y));
    }
  }
}