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 std::max;
using std::min;
using std::multiset;
using std::sort;
using std::swap;
const int maxn = 200007;
const int maxm = 400007;
const int inf = 0x7f7f7f7f;
struct E {
  int v;
};
struct Graph {
  E e[maxm];
  int first[maxn], nt[maxm], ES;
  inline void addE(int u, int v) {
    e[++ES] = (E){v};
    nt[ES] = first[u];
    first[u] = ES;
    return;
  }
} T, G;
int N, M, cnt, Q;
int dfn[maxn], low[maxn], ix;
int stk[maxn], Top;
int A[maxn];
multiset<int> s[maxn];
void tarjan(int u) {
  low[u] = dfn[u] = ++ix;
  stk[++Top] = u;
  for (int v, i = G.first[u]; i; i = G.nt[i]) {
    v = G.e[i].v;
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        ++cnt;
        int p;
        do {
          p = stk[Top--];
          T.addE(p, cnt);
          T.addE(cnt, p);
        } while (p != v);
        T.addE(cnt, u);
        T.addE(u, cnt);
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
  return;
}
int dep[maxn], sz[maxn], son[maxn], fa[maxn];
void dfs(int u) {
  sz[u] = 1;
  for (int v, i = T.first[u]; i; i = T.nt[i]) {
    v = T.e[i].v;
    if (v == fa[u]) continue;
    dep[v] = dep[u] + 1;
    fa[v] = u;
    dfs(v);
    if (u > N) s[u].insert(A[v]);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
  if (u > N && !s[u].empty()) A[u] = *s[u].begin();
  return;
}
int top[maxn], id[maxn], anti[maxn];
void dfs(int u, int tp) {
  top[u] = tp;
  anti[id[u] = ++ix] = u;
  if (son[u]) dfs(son[u], tp);
  for (int v, i = T.first[u]; i; i = T.nt[i]) {
    v = T.e[i].v;
    if (v == fa[u] || v == son[u]) continue;
    dfs(v, v);
  }
  return;
}
int mn[maxn << 2];
void build(int L, int R, int i) {
  if (L == R) {
    mn[i] = A[anti[L]];
    return;
  }
  int mid = L + R >> 1;
  build(L, mid, (i << 1));
  build(mid + 1, R, (i << 1 | 1));
  mn[i] = min(mn[(i << 1)], mn[(i << 1 | 1)]);
  return;
}
void update(int L, int R, int x, int k, int i) {
  if (L == R) {
    mn[i] = (A[anti[L]] = k);
    return;
  }
  int mid = L + R >> 1;
  if (x <= mid)
    update(L, mid, x, k, (i << 1));
  else
    update(mid + 1, R, x, k, (i << 1 | 1));
  mn[i] = min(mn[(i << 1)], mn[(i << 1 | 1)]);
  return;
}
int query(int L, int R, int l, int r, int i) {
  if (l <= L && R <= r) return mn[i];
  int re = inf, mid = L + R >> 1;
  if (l <= mid) re = min(re, query(L, mid, l, r, (i << 1)));
  if (r > mid) re = min(re, query(mid + 1, R, l, r, (i << 1 | 1)));
  return re;
}
int query(int x, int y) {
  int re = inf;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    re = min(re, query(1, cnt, id[top[x]], id[x], 1));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  re = min(re, query(1, cnt, id[x], id[y], 1));
  if (x > N) re = min(re, A[fa[x]]);
  return re;
}
int main() {
  scanf("%d%d%d", &N, &M, &Q);
  cnt = N;
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
  int u, v;
  for (int i = 1; i <= M; i++) {
    scanf("%d%d", &u, &v);
    G.addE(u, v);
    G.addE(v, u);
  }
  for (int i = 1; i <= N; i++)
    if (!dfn[i]) tarjan(i);
  ix = 0;
  dfs(1);
  dfs(1, 1);
  build(1, cnt, 1);
  char src[7];
  multiset<int>::iterator it;
  while (Q--) {
    scanf("%s", src + 1);
    scanf("%d%d", &u, &v);
    if (src[1] == 'C') {
      if (fa[u] > N) {
        it = s[fa[u]].lower_bound(A[u]);
        s[fa[u]].erase(it);
        s[fa[u]].insert(A[u] = v);
        update(1, cnt, id[fa[u]], *s[fa[u]].begin(), 1);
      }
      update(1, cnt, id[u], v, 1);
    } else
      printf("%d\n", query(u, v));
  }
  return 0;
}