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 INF = 2e9 + 9;
const int mxn = 2e5 + 5;
int n, m, q, dis[mxn], ext;
vector<int> G1[mxn], G2[mxn];
multiset<int> S[mxn];
int minn[mxn << 2];
int pos, dfn[mxn], low[mxn], topp, sta[mxn];
int dep[mxn], f[mxn], size[mxn], id[mxn], cnt, h[mxn], top[mxn], loc[mxn];
void build_tree(int o, int l, int r) {
  if (l == r) {
    minn[o] = dis[loc[l]];
    return;
  }
  int md = l + r >> 1;
  build_tree(o << 1, l, md);
  build_tree(o << 1 | 1, md + 1, r);
  minn[o] = min(minn[o << 1], minn[o << 1 | 1]);
}
void update(int o, int l, int r, int x, int k) {
  if (l == r) {
    minn[o] = k;
    return;
  }
  int md = l + r >> 1;
  if (x <= md)
    update(o << 1, l, md, x, k);
  else
    update(o << 1 | 1, md + 1, r, x, k);
  minn[o] = min(minn[o << 1], minn[o << 1 | 1]);
}
int query(int o, int l, int r, int x, int y) {
  if (x <= l and r <= y) return minn[o];
  int md = l + r >> 1, ret = INF;
  if (x <= md) ret = min(ret, query(o << 1, l, md, x, y));
  if (md < y) ret = min(ret, query(o << 1 | 1, md + 1, r, x, y));
  return ret;
}
void dfs1(int x, int fa) {
  f[x] = fa;
  dep[x] = dep[fa] + 1;
  size[x] = 1;
  int tmp = -1;
  for (int i = 0; i < G2[x].size(); ++i) {
    int v = G2[x][i];
    if (v == fa) continue;
    dfs1(v, x);
    size[x] += size[v];
    if (size[v] > tmp) {
      tmp = size[v];
      h[x] = v;
    }
  }
}
void dfs2(int x, int fa) {
  top[x] = fa;
  id[x] = ++cnt;
  loc[cnt] = x;
  if (!h[x]) return;
  dfs2(h[x], fa);
  for (int i = 0; i < G2[x].size(); ++i) {
    int v = G2[x][i];
    if (v == f[x] or v == h[x]) continue;
    dfs2(v, v);
  }
}
void tarjan(int x) {
  dfn[x] = low[x] = ++pos;
  sta[++topp] = x;
  for (int i = 0; i < G1[x].size(); ++i) {
    int v = G1[x][i];
    if (!dfn[v]) {
      tarjan(v);
      low[x] = min(low[x], low[v]);
      if (low[v] == dfn[x]) {
        ++ext;
        for (int j = 0; j != v; topp--) {
          j = sta[topp];
          G2[ext].push_back(j);
          G2[j].push_back(ext);
        }
        G2[ext].push_back(x);
        G2[x].push_back(ext);
      }
    } else
      low[x] = min(low[x], dfn[v]);
  }
}
inline int querypath(int x, int y) {
  int ret = INF;
  for (; top[x] != top[y];) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ret = min(ret, query(1, 1, ext, id[top[x]], id[x]));
    x = f[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  ret = min(ret, query(1, 1, ext, id[x], id[y]));
  if (x > n) ret = min(ret, dis[f[x]]);
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  ext = n;
  for (int i = 1; i <= n; ++i) scanf("%d", &dis[i]);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G1[u].push_back(v);
    G1[v].push_back(u);
  }
  tarjan(1);
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i)
    if (f[i]) S[f[i]].insert(dis[i]);
  for (int i = n + 1; i <= ext; ++i) dis[i] = *S[i].begin();
  build_tree(1, 1, ext);
  for (; q--;) {
    char s[5];
    scanf("%s", s);
    if (s[0] == 'C') {
      int x, y;
      scanf("%d%d", &x, &y);
      update(1, 1, ext, id[x], y);
      if (f[x]) {
        S[f[x]].erase(S[f[x]].lower_bound(dis[x]));
        S[f[x]].insert(y);
        if (dis[f[x]] != *S[f[x]].begin()) {
          dis[f[x]] = *S[f[x]].begin();
          update(1, 1, ext, id[f[x]], dis[f[x]]);
        }
      }
      dis[x] = y;
    } else if (s[0] == 'A') {
      int x, y;
      scanf("%d%d", &x, &y);
      printf("%d\n", querypath(x, y));
    }
  }
  return 0;
}