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;
inline int read() {
  int x = 0, f = 1;
  char p = getchar();
  while (!isdigit(p)) {
    if (p == '-') f = -1;
    p = getchar();
  }
  while (isdigit(p)) x = (x << 3) + (x << 1) + (p ^ 48), p = getchar();
  return x * f;
}
const int maxn = 4e5 + 5;
int head[maxn], ver[maxn], nxt[maxn], cnt, w[maxn], n, m, q;
int dfn[maxn], stk[maxn], z, low[maxn], tim, num;
vector<int> vec[maxn];
multiset<int> s[maxn];
inline void add(int x, int y) {
  nxt[++cnt] = head[x];
  head[x] = cnt;
  ver[cnt] = y;
}
namespace tree {
int tree[maxn << 1], son[maxn], siz[maxn], dep[maxn], f[maxn];
int node_cnt, top[maxn], yx[maxn];
inline void dfs1(int x, int fa) {
  siz[x] = 1;
  dep[x] = dep[fa] + 1;
  f[x] = fa;
  if (x <= n && fa) s[fa].insert(w[x]);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == fa) continue;
    dfs1(y, x);
    siz[x] += siz[y];
    if (siz[y] > siz[son[x]]) son[x] = y;
  }
}
inline void dfs2(int x, int tp) {
  dfn[x] = ++node_cnt;
  top[x] = tp;
  yx[node_cnt] = x;
  if (son[x]) dfs2(son[x], tp);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == son[x] || y == f[x]) continue;
    dfs2(y, y);
  }
}
inline void pushup(int k) { tree[k] = min(tree[k << 1], tree[k << 1 | 1]); }
inline void build(int k, int l, int r) {
  if (l == r) {
    tree[k] = w[yx[l]];
    return;
  }
  build(k << 1, l, ((l + r) >> 1));
  build(k << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(k);
}
inline void update(int k, int l, int r, int pos, int dat) {
  if (l == r) {
    tree[k] = dat;
    return;
  }
  if (pos <= ((l + r) >> 1))
    update(k << 1, l, ((l + r) >> 1), pos, dat);
  else
    update(k << 1 | 1, ((l + r) >> 1) + 1, r, pos, dat);
  pushup(k);
}
inline int query(int k, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tree[k];
  int ans = 1e9;
  if (L <= ((l + r) >> 1))
    ans = min(ans, query(k << 1, l, ((l + r) >> 1), L, R));
  if (R > ((l + r) >> 1))
    ans = min(ans, query(k << 1 | 1, ((l + r) >> 1) + 1, r, L, R));
  return ans;
}
inline void change(int x, int dat) {
  if (f[x]) {
    s[f[x]].erase(s[f[x]].find(w[x]));
    s[f[x]].insert(dat);
    update(1, 1, num, dfn[f[x]], *s[f[x]].begin());
  }
  w[x] = dat;
  update(1, 1, num, dfn[x], w[x]);
}
inline int Q(int x, int y) {
  int ret = 1e9;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ret = min(ret, query(1, 1, num, dfn[top[x]], dfn[x]));
    x = f[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  ret = min(ret, query(1, 1, num, dfn[x], dfn[y]));
  if (x <= n)
    return ret;
  else
    return min(ret, w[f[x]]);
}
}  // namespace tree
using namespace tree;
inline void tarjan(int x) {
  stk[++z] = x;
  dfn[x] = low[x] = ++tim;
  for (int i = 0; i < vec[x].size(); i++) {
    int y = vec[x][i];
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (dfn[x] <= low[y]) {
        num++;
        add(num, x);
        add(x, num);
        int tmp;
        do {
          tmp = stk[z--];
          add(num, tmp);
          add(tmp, num);
        } while (tmp != y);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
int main() {
  num = n = read();
  m = read();
  q = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1, x, y; i <= m; i++)
    x = read(), y = read(), vec[x].push_back(y), vec[y].push_back(x);
  tarjan(1);
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = n + 1; i <= num; i++) w[i] = *s[i].begin();
  build(1, 1, num);
  while (q--) {
    char opt;
    cin >> opt;
    int a = read(), b = read();
    if (opt == 'A') {
      printf("%d\n", Q(a, b));
      continue;
    }
    if (opt == 'C') {
      change(a, b);
      continue;
    }
  }
  return 0;
}