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 char gc() {
  static char now[1 << 16], *S, *T;
  if (S == T) {
    T = (S = now) + fread(now, 1, 1 << 16, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
inline int read() {
  int x = 0, f = 1;
  char c = gc();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = gc();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = gc();
  }
  return x * f;
}
struct edge {
  int to, next;
} e[200010 << 1];
struct node {
  int u, v;
} g[200010];
int head[200010], w[200010], bel[200010], iscut[200010], val[200010];
int n, m, Q, cnt;
map<int, int> has[200010];
namespace ufs {
int fa[200010];
int getfa(int x) { return (x == fa[x]) ? x : (fa[x] = getfa(fa[x])); }
}  // namespace ufs
using ufs::getfa;
inline void ins(int x, int y) {
  if (has[x][y]) return;
  has[x][y] = 1;
  if (getfa(x) == getfa(y)) return;
  ufs::fa[getfa(x)] = getfa(y);
  e[++cnt] = (edge){y, head[x]};
  head[x] = cnt;
  e[++cnt] = (edge){x, head[y]};
  head[y] = cnt;
}
inline void link(int x, int y) { ins(x, y); }
namespace G {
struct edge {
  int to, next;
} e[200010 << 1];
int head[200010], cnt;
inline void ins(int x, int y) {
  e[++cnt] = (edge){y, head[x]};
  head[x] = cnt;
}
int dfn[200010], low[200010], tim, bcc, bcc_size[200010];
inline void init() {
  memset(head, 0, sizeof(head));
  cnt = 1;
  tim = bcc = 0;
  memset(bel, 0, sizeof(bel));
  memset(iscut, 0, sizeof(iscut));
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(bcc_size, 0, sizeof(bcc_size));
}
stack<int> sta;
void tarjan(int u, int f) {
  dfn[u] = low[u] = ++tim;
  int child = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    if (!dfn[v]) {
      sta.push(i);
      ++child;
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        iscut[u] = 1;
        ++bcc;
        while (true) {
          int edg = sta.top();
          sta.pop();
          int x = e[edg ^ 1].to, y = e[edg].to;
          if (bel[x] != bcc) {
            bel[x] = bcc;
            ++bcc_size[bcc];
            if (iscut[x]) link(n + bcc, x);
          }
          if (bel[y] != bcc) {
            bel[y] = bcc;
            ++bcc_size[bcc];
            if (iscut[y]) link(n + bcc, y);
          }
          if (x == u && y == v) break;
        }
      }
    } else if (dfn[v] < dfn[u])
      sta.push(i), low[u] = min(low[u], dfn[v]);
    if (!f && child == 1) iscut[u] = 0;
  }
}
}  // namespace G
int root, nocut = 1;
multiset<int> q[200010];
inline void build_tree() {
  for (int i = 1; i <= n; ++i) bel[i] += n;
  for (int u = 1; u <= n; ++u) {
    if (iscut[u]) {
      for (int i = G::head[u]; i; i = G::e[i].next) {
        int v = G::e[i].to;
        if (!iscut[v]) ins(bel[v], u);
      }
    } else
      q[bel[u]].insert(w[u]);
  }
  for (int i = 1; i <= m; ++i) {
    int u = g[i].u, v = g[i].v;
    if (iscut[u] && iscut[v] && getfa(u) != getfa(v)) ins(u, v);
  }
  if (iscut[1])
    root = 1;
  else
    root = bel[1];
  for (int i = 1; i <= n; ++i)
    if (iscut[i]) nocut = 0;
}
int sz[200010], fa[200010], dep[200010], son[200010], dfn[200010], tim = 0,
                                                                   tp[200010];
void dfs(int u) {
  sz[u] = 1;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa[u]) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    if (!iscut[u] && iscut[v]) q[u].insert(w[v]);
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs(int u, int anc) {
  dfn[u] = ++tim;
  val[tim] = w[u];
  tp[u] = anc;
  if (son[u]) dfs(son[u], anc);
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v != fa[u] && v != son[u]) dfs(v, v);
  }
}
namespace segt {
int t[200010 << 2];
void build(int x, int l, int r) {
  if (l == r)
    t[x] = val[l];
  else {
    build(x << 1, l, ((l + r) >> 1));
    build(x << 1 | 1, ((l + r) >> 1) + 1, r);
    t[x] = min(t[x << 1], t[x << 1 | 1]);
  }
}
void cha(int x, int l, int r, int p, int v) {
  if (l == r)
    t[x] = v;
  else {
    if (p <= ((l + r) >> 1))
      cha(x << 1, l, ((l + r) >> 1), p, v);
    else
      cha(x << 1 | 1, ((l + r) >> 1) + 1, r, p, v);
    t[x] = min(t[x << 1], t[x << 1 | 1]);
  }
}
int que(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr)
    return t[x];
  else {
    int ret = 0x7fffffff;
    if (ql <= ((l + r) >> 1))
      ret = min(ret, que(x << 1, l, ((l + r) >> 1), ql, qr));
    if (((l + r) >> 1) + 1 <= qr)
      ret = min(ret, que(x << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr));
    return ret;
  }
}
}  // namespace segt
using segt::cha;
using segt::que;
inline void bcc_cha(int id, int u, int ww) {
  q[id].erase(q[id].find(w[u]));
  w[u] = ww;
  q[id].insert(w[u]);
  w[id] = *q[id].begin();
  if (!nocut) cha(1, 1, tim, dfn[id], w[id]);
}
inline void bcc_cha2(int id, int last_w, int now_w) {
  q[id].erase(q[id].find(last_w));
  q[id].insert(now_w);
  w[id] = *q[id].begin();
  cha(1, 1, tim, dfn[id], w[id]);
}
inline void change(int u, int ww) {
  if (iscut[u]) {
    int last_w = w[u];
    w[u] = ww;
    cha(1, 1, tim, dfn[u], ww);
    int f = fa[u];
    if (f && !iscut[f]) bcc_cha2(f, last_w, ww);
  } else
    bcc_cha(bel[u], u, ww);
}
inline void query(int x, int y) {
  if (x == y) {
    printf("%d\n", w[x]);
    return;
  }
  if (!iscut[x]) x = bel[x];
  if (!iscut[y]) y = bel[y];
  int ans = 0x7fffffff;
  while (tp[x] != tp[y]) {
    if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
    ans = min(ans, que(1, 1, tim, dfn[tp[x]], dfn[x]));
    x = fa[tp[x]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  ans = min(ans, que(1, 1, tim, dfn[x], dfn[y]));
  if (!iscut[x] && fa[x]) ans = min(ans, w[fa[x]]);
  printf("%d\n", ans);
}
int main() {
  n = read();
  m = read();
  Q = read();
  for (int i = 1; i <= n; ++i) w[i] = read();
  G::init();
  cnt = 1;
  memset(head, 0, sizeof(head));
  for (int i = 1; i <= n << 1; ++i) ufs::fa[i] = i;
  for (int i = 1; i <= m; ++i) {
    g[i].u = read();
    g[i].v = read();
    G::ins(g[i].u, g[i].v);
    G::ins(g[i].v, g[i].u);
  }
  G::tarjan(1, 0);
  build_tree();
  char opt;
  if (nocut) {
    w[n + 1] = *q[n + 1].begin();
    for (int i = 1; i <= Q; ++i) {
      opt = gc();
      while (opt != 'C' && opt != 'A') opt = gc();
      int x = read(), y = read();
      if (opt == 'C')
        bcc_cha(n + 1, x, y);
      else
        printf("%d\n", x == y ? w[x] : w[n + 1]);
    }
    return 0;
  }
  dfs(root);
  dfs(root, root);
  for (int i = 1; i <= G::bcc; ++i)
    w[i + n] = *q[i + n].begin(), val[dfn[i + n]] = w[i + n];
  segt::build(1, 1, tim);
  for (int i = 1; i <= Q; ++i) {
    opt = gc();
    while (opt != 'C' && opt != 'A') opt = gc();
    int x = read(), y = read();
    if (opt == 'C')
      change(x, y);
    else
      query(x, y);
  }
  return 0;
}