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 = 412345;
int n, m, q, tot, W[maxn], DFN[maxn], LOW[maxn], tim;
stack<int> stk;
vector<int> adj[maxn], G[maxn];
void tarjan(int u) {
  DFN[u] = LOW[u] = ++tim;
  stk.push(u);
  for (int i = 0; i < (int)adj[u].size(); ++i) {
    int v = adj[u][i];
    if (!DFN[v]) {
      tarjan(v);
      LOW[u] = min(LOW[u], LOW[v]);
      if (LOW[v] >= DFN[u]) {
        ++tot;
        G[u].push_back(tot);
        G[tot].push_back(u);
        int x;
        do {
          x = stk.top();
          stk.pop();
          G[x].push_back(tot);
          G[tot].push_back(x);
        } while (v != x);
      }
    } else
      LOW[u] = min(LOW[u], DFN[v]);
  }
}
multiset<int> st[maxn];
int dep[maxn], dfn[maxn], fa[maxn], sz[maxn], son[maxn], top[maxn];
void dfs1(int u, int ff) {
  fa[u] = ff;
  dep[u] = dep[ff] + 1;
  sz[u] = 1;
  if (u <= n && ff) st[ff].insert(W[u]);
  for (int i = 0; i < (int)G[u].size(); ++i) {
    int v = G[u][i];
    if (v == ff) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++tim;
  if (son[u]) dfs2(son[u], tp);
  for (int i = 0; i < (int)G[u].size(); ++i) {
    int v = G[u][i];
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
int seg[maxn << 2];
void update(int x, int l, int r, int p, int v) {
  if (l == r) {
    seg[x] = v;
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m)
    update(x << 1, l, m, p, v);
  else
    update(x << 1 | 1, m + 1, r, p, v);
  seg[x] = min(seg[x << 1], seg[x << 1 | 1]);
}
int query(int x, int L, int R, int l, int r) {
  if (l <= L && r >= R) return seg[x];
  int ret = 1123456789, m = (L + R) >> 1;
  if (l <= m) ret = min(ret, query(x << 1, L, m, l, r));
  if (m < r) ret = min(ret, query(x << 1 | 1, m + 1, R, l, r));
  return ret;
}
char op[2];
inline int query(int u, int v) {
  int ret = 1123456789;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    ret = min(ret, query(1, 1, tot, dfn[top[u]], dfn[u]));
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  ret = min(ret, query(1, 1, tot, dfn[u], dfn[v]));
  if (u <= n) return ret;
  return min(ret, W[fa[u]]);
}
inline void update(int u, int w) {
  if (fa[u]) {
    st[fa[u]].erase(st[fa[u]].find(W[u]));
    st[fa[u]].insert(w);
    update(1, 1, tot, dfn[fa[u]], *st[fa[u]].begin());
  }
  W[u] = w;
  update(1, 1, tot, dfn[u], w);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  tot = n;
  W[0] = 1123456789;
  for (int i = 1; i <= n; ++i) scanf("%d", &W[i]);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  tarjan(1);
  tim = 0;
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i) update(1, 1, tot, dfn[i], W[i]);
  for (int i = n + 1; i <= tot; ++i) update(1, 1, tot, dfn[i], *st[i].begin());
  while (q--) {
    int u, v;
    scanf("%s%d%d", op, &u, &v);
    if (op[0] == 'C')
      update(u, v);
    else
      printf("%d\n", query(u, v));
  }
  return 0;
}