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;
const int maxn = 4e5 + 100;
int n, m, q, x, y, tot;
int w[maxn], dfn[maxn], top[maxn], fa[maxn], siz[maxn], dep[maxn], blo[maxn],
    num[maxn], pre[maxn], son[maxn];
vector<int> f[maxn], e[maxn];
int low[maxn], sig;
stack<int> S;
set<int>::iterator it;
multiset<int> g[maxn];
void tarjan(int u, int fath) {
  dfn[u] = low[u] = ++tot;
  S.push(u);
  for (int i = 0; i < f[u].size(); i++) {
    int v = f[u][i];
    if (v == fath) continue;
    if (!dfn[v]) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        ++sig;
        e[u].push_back(sig);
        int tp;
        do {
          tp = S.top();
          S.pop();
          blo[tp] = sig;
          e[sig].push_back(tp);
          g[sig].insert(w[tp]);
        } while (tp != v);
        w[sig] = *(g[sig].begin());
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
void dfs1(int u) {
  siz[u] = 1;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa[u]) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    dfs1(v);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  pre[num[u] = ++tot] = u;
  if (!son[u]) return;
  dfs2(son[u], tp);
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v != fa[u] && v != son[u]) dfs2(v, v);
  }
}
int T[maxn * 4];
void push_up(int rt) { T[rt] = min(T[rt << 1], T[rt << 1 | 1]); }
void build(int rt, int l, int r) {
  if (l == r) {
    T[rt] = w[pre[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  push_up(rt);
}
void update(int rt, int l, int r, int pos, int val) {
  if (l == r) {
    T[rt] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(rt << 1, l, mid, pos, val);
  else
    update(rt << 1 | 1, mid + 1, r, pos, val);
  push_up(rt);
}
int query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) return T[rt];
  int res = 1e9 + 100;
  int mid = (l + r) >> 1;
  if (L <= mid) res = min(res, query(rt << 1, l, mid, L, R));
  if (R > mid) res = min(res, query(rt << 1 | 1, mid + 1, r, L, R));
  return res;
}
int ask(int x, int y) {
  int res = 1e9 + 100;
  while (top[x] ^ top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    res = min(res, query(1, 1, sig, num[top[x]], num[x]));
    x = fa[top[x]];
  }
  if (dep[x] < dep[y]) swap(x, y);
  res = min(res, query(1, 1, sig, num[y], num[x]));
  if (y > n && fa[y]) res = min(res, w[fa[y]]);
  return res;
}
void change(int u, int val) {
  if (blo[u]) {
    it = g[blo[u]].find(w[u]);
    g[blo[u]].erase(it);
    g[blo[u]].insert(val);
    w[blo[u]] = *(g[blo[u]].begin());
    update(1, 1, sig, num[blo[u]], w[blo[u]]);
  }
  w[u] = val;
  update(1, 1, sig, num[u], val);
}
char s[5];
int main() {
  cin >> n >> m >> q;
  sig = n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    f[x].push_back(y);
    f[y].push_back(x);
  }
  tarjan(1, 0);
  dfs1(1);
  tot = 0;
  dfs2(1, 1);
  build(1, 1, sig);
  for (int i = 1; i <= q; i++) {
    scanf("%s", s);
    cin >> x >> y;
    if (s[0] == 'C')
      change(x, y);
    else
      printf("%d\n", ask(x, y));
  }
  return 0;
}