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 = 2000000000;
int n, m, q, w[200005];
int dfn[200005], low[200005], c, col, st[200005], tp;
int seg[200005], rev[200005], top[200005], fa[200005], siz[200005], son[200005],
    dep[200005], hfu;
int mn[200005 << 2];
vector<int> s[200005], tr[200005];
multiset<int> val[200005];
template <class T>
inline T Min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T Max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline void read(T &x) {
  char c;
  int sign = 1;
  while ((c = getchar()) > '9' || c < '0')
    if (c == '-') sign = -1;
  x = c - 48;
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - 48;
  x *= sign;
}
void add1(int x, int y) {
  s[x].push_back(y);
  s[y].push_back(x);
}
void add2(int x, int y) {
  tr[x].push_back(y);
  tr[y].push_back(x);
}
void tarjan(int rt, int fa) {
  st[++tp] = rt;
  dfn[rt] = low[rt] = ++c;
  for (int i = 0, t = s[rt].size(); i < t; ++i) {
    int v = s[rt][i];
    if (v == fa) continue;
    if (!dfn[v]) {
      tarjan(v, rt);
      low[rt] = Min(low[rt], low[v]);
      if (dfn[rt] <= low[v]) {
        ++col;
        add2(col, rt);
        while (st[tp] != v) add2(col, st[tp]), --tp;
        add2(col, v);
        --tp;
      }
    } else
      low[rt] = Min(low[rt], dfn[v]);
  }
}
void dfs1(int rt) {
  siz[rt] = 1;
  dep[rt] = dep[fa[rt]] + 1;
  if (fa[rt] > n) val[fa[rt]].insert(w[rt]);
  for (int i = 0, t = tr[rt].size(); i < t; ++i) {
    int v = tr[rt][i];
    if (v == fa[rt]) continue;
    fa[v] = rt;
    dfs1(v);
    siz[rt] += siz[v];
    if (siz[v] > siz[son[rt]]) son[rt] = v;
  }
}
void dfs2(int rt) {
  if (son[rt]) {
    seg[son[rt]] = ++hfu;
    rev[hfu] = son[rt];
    top[son[rt]] = top[rt];
    dfs2(son[rt]);
  }
  for (int i = 0, t = tr[rt].size(); i < t; ++i) {
    int v = tr[rt][i];
    if (v == fa[rt] || v == son[rt]) continue;
    seg[v] = ++hfu;
    rev[hfu] = v;
    top[v] = v;
    dfs2(v);
  }
}
inline void pushup(int rt) { mn[rt] = Min(mn[rt << 1], mn[rt << 1 | 1]); }
inline int lca(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
void build(int rt, int l, int r) {
  if (l == r) {
    mn[rt] = rev[l] <= n ? inf : *val[rev[l]].begin();
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  pushup(rt);
}
void modify(int rt, int l, int r, int x, int v) {
  if (l == r) return (void)(mn[rt] = v);
  int mid = (l + r) >> 1;
  if (x <= mid)
    modify(rt << 1, l, mid, x, v);
  else
    modify(rt << 1 | 1, mid + 1, r, x, v);
  pushup(rt);
}
int query(int rt, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[rt];
  int mid = (l + r) >> 1;
  int ret = inf;
  if (x <= mid) ret = Min(ret, query(rt << 1, l, mid, x, y));
  if (y > mid) ret = Min(ret, query(rt << 1 | 1, mid + 1, r, x, y));
  return ret;
}
int query_edge(int x, int y) {
  int ret = inf, fx = top[x], fy = top[y];
  while (fx != fy) {
    if (dep[fx] < dep[fy]) swap(x, y), swap(fx, fy);
    ret = Min(ret, query(1, 1, hfu, seg[fx], seg[x]));
    x = fa[fx];
    fx = top[x];
  }
  if (dep[x] > dep[y]) swap(x, y);
  return Min(ret, query(1, 1, hfu, seg[x], seg[y]));
}
int main() {
  read(n);
  read(m);
  read(q);
  col = n;
  for (int i = 1; i <= n; ++i) read(w[i]);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add1(x, y);
  }
  tarjan(1, 0);
  seg[1] = rev[1] = top[1] = hfu = 1;
  dfs1(1);
  dfs2(1);
  build(1, 1, hfu);
  while (q--) {
    char op[2];
    int x, y;
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'A') {
      int ans = query_edge(x, y), l = lca(x, y);
      if (l > n)
        ans = Min(ans, w[fa[l]]);
      else
        ans = Min(ans, w[l]);
      printf("%d\n", ans);
    } else {
      if (fa[x]) {
        set<int>::iterator it = val[fa[x]].find(w[x]);
        val[fa[x]].erase(it);
        val[fa[x]].insert(y);
        modify(1, 1, hfu, seg[fa[x]], *val[fa[x]].begin());
      }
      w[x] = y;
    }
  }
  return 0;
}