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 c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return f ? x : -x;
}
int n, m, q, w[100005 << 1], tot;
namespace Tree {
struct egde {
  int nxt, to;
} e[(100005 << 1) << 1];
int num_edge, head[(100005 << 1)];
multiset<int> s[(100005 << 1)];
int dfn[(100005 << 1)], tmr, rev[(100005 << 1)], fa[(100005 << 1)],
    top[(100005 << 1)], son[(100005 << 1)], siz[(100005 << 1)],
    dep[(100005 << 1)];
int val[((100005 << 1) << 2)];
void addedge(int fr, int to) {
  ++num_edge;
  e[num_edge].nxt = head[fr];
  e[num_edge].to = to;
  head[fr] = num_edge;
}
void dfs1(int u, int ft) {
  siz[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == ft) continue;
    fa[v] = u, dep[v] = dep[u] + 1, dfs1(v, u), siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  rev[dfn[u] = ++tmr] = u, top[u] = tp;
  if (son[u]) dfs2(son[u], tp);
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
void pushup(int p) { val[p] = min(val[(p << 1)], val[(p << 1 | 1)]); }
void build(int l = 1, int r = tot, int p = 1) {
  if (l == r) return val[p] = w[rev[l]], void();
  int mid = (l + r) >> 1;
  build(l, mid, (p << 1)), build(mid + 1, r, (p << 1 | 1));
  pushup(p);
}
void change(int pos, int k, int l = 1, int r = tot, int p = 1) {
  if (l == r) return val[p] = k, void();
  int mid = (l + r) >> 1;
  if (pos <= mid)
    change(pos, k, l, mid, (p << 1));
  else
    change(pos, k, mid + 1, r, (p << 1 | 1));
  pushup(p);
}
int query_min(int ql, int qr, int l = 1, int r = tot, int p = 1) {
  if (ql <= l && r <= qr) return val[p];
  int mid = (l + r) >> 1, res = 1000000007;
  if (ql <= mid) res = min(res, query_min(ql, qr, l, mid, (p << 1)));
  if (mid < qr) res = min(res, query_min(ql, qr, mid + 1, r, (p << 1 | 1)));
  return res;
}
int ask_min(int x, int y) {
  int res = 1000000007;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) x ^= y ^= x ^= y;
    res = min(res, query_min(dfn[top[x]], dfn[x])), x = fa[top[x]];
  }
  if (dfn[x] > dfn[y]) x ^= y ^= x ^= y;
  return min(res, query_min(dfn[x], dfn[y]));
}
void modify(int x, int y) {
  if (fa[x] > n) {
    s[fa[x]].erase(s[fa[x]].find(w[x]));
    s[fa[x]].insert(y);
    if (w[fa[x]] != *s[fa[x]].begin()) {
      w[fa[x]] = *s[fa[x]].begin();
      change(dfn[fa[x]], w[fa[x]]);
    }
  }
  change(dfn[x], w[x] = y);
}
int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) x ^= y ^= x ^= y;
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
int query(int x, int y) {
  int res = ask_min(x, y), lca = LCA(x, y);
  if (lca > n) res = min(res, w[fa[lca]]);
  return res;
}
void init() {
  dfs1(1, 0), dfs2(1, 1);
  for (int i = 1; i <= n; ++i) s[fa[i]].insert(w[i]);
  for (int i = n + 1; i <= tot; ++i) w[i] = *s[i].begin();
  build();
}
}  // namespace Tree
namespace cst {
int dfn[100005], tmr, low[100005], stk[100005], top;
struct egde {
  int nxt, to;
} e[100005 << 1];
int num_edge, head[100005];
void addedge(int fr, int to) {
  ++num_edge;
  e[num_edge].nxt = head[fr];
  e[num_edge].to = to;
  head[fr] = num_edge;
}
void tarjan(int u) {
  dfn[u] = low[u] = ++tmr, stk[++top] = u;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (!dfn[v]) {
      tarjan(v), low[u] = min(low[u], low[v]);
      if (dfn[u] == low[v]) {
        ++tot;
        Tree::addedge(tot, u), Tree::addedge(u, tot);
        while (stk[top + 1] != v) {
          Tree::addedge(tot, stk[top]), Tree::addedge(stk[top], tot), --top;
        }
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
}  // namespace cst
signed main() {
  tot = n = read(), m = read(), q = read();
  for (int i = 1; i <= n; ++i) w[i] = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    cst::addedge(x, y), cst::addedge(y, x);
  }
  cst::tarjan(1), Tree::init();
  while (q--) {
    char ch = getchar();
    while (ch != 'C' && ch != 'A') ch = getchar();
    int x = read(), y = read();
    if (ch == 'C')
      Tree::modify(x, y);
    else
      printf("%d\n", Tree::query(x, y));
  }
  return 0;
}