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>
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int inf = 2147483647;
const int mod = 1e9 + 7;
inline long long read() {
  long long d = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') d = d * 10 + ch - 48, ch = getchar();
  return d * w;
}
inline void file() {
  freopen(
      "a"
      ".in",
      "r", stdin);
  freopen(
      "a"
      ".out",
      "w", stdout);
}
int n, m, q, tot;
struct graph {
  int head[N], nxt[N << 1], to[N << 1], cnt;
  inline void add(int u, int v) {
    to[++cnt] = v;
    nxt[cnt] = head[u];
    head[u] = cnt;
    to[++cnt] = u;
    nxt[cnt] = head[v];
    head[v] = cnt;
  }
} g1, g2;
int VAL[N];
struct heap {
  priority_queue<int, vector<int>, greater<int> > a, b;
  inline void push(int x) { a.push(x); }
  inline void erase(int x) { b.push(x); }
  inline int top() {
    while (!b.empty() && a.top() == b.top()) a.pop(), b.pop();
    return a.top();
  }
} H[N];
int dfn[N], low[N], cntw, cal[N], cov;
void tarjan(int u) {
  dfn[u] = low[u] = ++cntw;
  cal[++cov] = u;
  for (int i = g1.head[u], v; i; i = g1.nxt[i])
    if (!dfn[v = g1.to[i]]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        tot++;
        g2.add(tot, u);
        int x = 0;
        do g2.add(tot, x = cal[cov--]);
        while (x != v);
      }
    } else
      low[u] = min(low[u], dfn[v]);
}
int fa[N], sz[N], dep[N], son[N], TOP[N], w[N], fw[N];
void dfs1(int u, int ff) {
  fa[u] = ff;
  sz[u] = 1;
  dep[u] = dep[ff] + 1;
  son[u] = 0;
  for (int i = g2.head[u], v; i; i = g2.nxt[i]) {
    v = g2.to[i];
    if (v == ff) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    if (v <= n) H[u].push(VAL[v]);
    if (sz[son[u]] < sz[v]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  TOP[u] = tp;
  w[u] = ++cntw;
  fw[cntw] = u;
  if (son[u]) dfs2(son[u], tp);
  for (int i = g2.head[u], v; i; i = g2.nxt[i]) {
    v = g2.to[i];
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
inline int lca(int u, int v) {
  while (TOP[u] != TOP[v])
    dep[TOP[u]] > dep[TOP[v]] ? u = fa[TOP[u]] : v = fa[TOP[v]];
  return dep[u] < dep[v] ? u : v;
}
int mn[N << 2];
inline void update(int i) { mn[i] = min(mn[(i << 1)], mn[(i << 1 | 1)]); }
void build(int i, int l, int r) {
  if (l == r) {
    mn[i] = fw[l] <= n ? VAL[fw[l]] : H[fw[l]].top();
    return;
  }
  build((i << 1), l, ((l + r) >> 1));
  build((i << 1 | 1), ((l + r) >> 1) + 1, r);
  update(i);
}
void insert(int i, int l, int r, int p, int v) {
  if (l == r) {
    mn[i] = v;
    return;
  }
  p <= ((l + r) >> 1) ? insert((i << 1), l, ((l + r) >> 1), p, v)
                      : insert((i << 1 | 1), ((l + r) >> 1) + 1, r, p, v);
  update(i);
}
int query(int i, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[i];
  int s = inf;
  if (x <= ((l + r) >> 1)) s = query((i << 1), l, ((l + r) >> 1), x, y);
  if (((l + r) >> 1) < y)
    s = min(s, query((i << 1 | 1), ((l + r) >> 1) + 1, r, x, y));
  return s;
}
inline void Modify(int u, int v) {
  if (fa[u]) H[fa[u]].erase(VAL[u]);
  VAL[u] = v;
  if (fa[u]) H[fa[u]].push(v);
  insert(1, 1, tot, w[u], VAL[u]);
  if (fa[u]) insert(1, 1, tot, w[fa[u]], H[fa[u]].top());
}
inline int Query(int u, int v) {
  int res = inf;
  while (TOP[u] != TOP[v]) {
    if (dep[TOP[u]] < dep[TOP[v]]) swap(u, v);
    res = min(res, query(1, 1, tot, w[TOP[u]], w[u]));
    u = fa[TOP[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  res = min(res, query(1, 1, tot, w[u], w[v]));
  if (u > n) res = min(res, VAL[fa[u]]);
  return res;
}
int main() {
  n = read();
  m = read();
  q = read();
  tot = n;
  for (int i = 1; i <= n; i++) VAL[i] = read();
  for (int i = 1, u, v; i <= m; i++) {
    u = read();
    v = read();
    g1.add(u, v);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  cntw = 0;
  dfs1(1, 0);
  dfs2(1, 1);
  build(1, 1, tot);
  for (int i = 1, o, a, b; i <= q; i++) {
    o = 0;
    while (o != 'A' && o != 'C') o = getchar();
    a = read();
    b = read();
    if (o == 'A')
      printf("%d\n", Query(a, b));
    else
      Modify(a, b);
  }
  return 0;
}
