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;
template <class Tp>
void ckmin(Tp &x, Tp y) {
  x = (x < y) ? x : y;
}
template <class Tp>
void ckmax(Tp &x, Tp y) {
  x = (x < y) ? y : x;
}
template <class Tp>
Tp read() {
  Tp res = 0, f_f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f_f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    res = (res << 3) + (res << 1) + (ch - '0'), ch = getchar();
  return res * f_f;
}
const int maxn = 100005;
const int INF = 1e9 + 7;
struct Edge {
  int from, to, nxt;
  Edge() {}
  Edge(int from, int to, int nxt) : from(from), to(to), nxt(nxt) {}
};
struct Graph {
  Edge edges[maxn << 2];
  int lst[maxn << 1], E_cnt;
  Edge &operator[](const int x) { return edges[x]; }
  void init() {
    memset(lst, -1, sizeof(lst));
    E_cnt = -1;
  }
  int front(int x) { return lst[x]; }
  void add(int from, int to) {
    edges[++E_cnt] = Edge(from, to, lst[from]);
    lst[from] = E_cnt;
  }
} G[2];
int n, m, q, w[maxn << 1];
int low[maxn], dfn[maxn << 1], stac[maxn], topc, dfs_clock, p_cnt;
bool isf[maxn << 1];
int fa[maxn << 1], dep[maxn << 1], topf[maxn << 1], son[maxn << 1],
    siz[maxn << 1];
multiset<int> S[maxn << 1];
inline void dfs1(int u, int cur, int ecur) {
  low[u] = dfn[u] = ++dfs_clock;
  stac[++topc] = u;
  for (int i = G[0].front(u); ~i; i = G[0][i].nxt) {
    Edge &e = G[0][i];
    if (ecur == (i ^ 1)) continue;
    if (dfn[e.to])
      low[u] = min(low[u], dfn[e.to]);
    else {
      dfs1(e.to, u, i);
      low[u] = min(low[u], low[e.to]);
    }
  }
  if (cur && low[u] >= dfn[cur]) {
    isf[++p_cnt] = true;
    while (1) {
      int x = stac[topc--];
      G[1].add(x, p_cnt), G[1].add(p_cnt, x);
      S[p_cnt].insert(w[x]);
      if (x == u) break;
    }
    G[1].add(cur, p_cnt), G[1].add(p_cnt, cur);
  }
}
inline void dfs2(int u, int cur) {
  son[u] = 0, siz[u] = 1, fa[u] = cur, dep[u] = dep[cur] + 1;
  for (int i = G[1].front(u); ~i; i = G[1][i].nxt) {
    Edge &e = G[1][i];
    if (e.to == cur) continue;
    dfs2(e.to, u), siz[u] += siz[e.to];
    if (!son[u] || siz[e.to] > siz[son[u]]) son[u] = e.to;
  }
}
inline void dfs3(int u, int tf) {
  topf[u] = tf, dfn[u] = ++dfs_clock;
  if (!son[u]) return;
  dfs3(son[u], tf);
  for (int i = G[1].front(u); ~i; i = G[1][i].nxt) {
    Edge &e = G[1][i];
    if (e.to == fa[u] || son[u] == e.to) continue;
    dfs3(e.to, e.to);
  }
}
namespace SEG {
int minv[maxn << 3];
inline void update(int o, int l, int r, int x, int v) {
  if (l == r && l == x) {
    minv[o] = v;
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid)
    update(o << 1, l, mid, x, v);
  else
    update(o << 1 | 1, mid + 1, r, x, v);
  minv[o] = min(minv[o << 1], minv[o << 1 | 1]);
}
inline int query(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    return minv[o];
  }
  int mid = l + r >> 1, res = INF;
  if (ql <= mid) ckmin(res, query(o << 1, l, mid, ql, qr));
  if (qr > mid) ckmin(res, query(o << 1 | 1, mid + 1, r, ql, qr));
  return res;
}
}  // namespace SEG
inline int query_range(int x, int y) {
  int res = INF;
  while (topf[x] ^ topf[y]) {
    if (dep[topf[x]] > dep[topf[y]]) swap(x, y);
    ckmin(res, SEG::query(1, 1, p_cnt, dfn[topf[y]], dfn[y]));
    y = fa[topf[y]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  ckmin(res, SEG::query(1, 1, p_cnt, dfn[x], dfn[y]));
  if (isf[x] && fa[x]) ckmin(res, w[fa[x]]);
  return res;
}
int main() {
  n = (read<int>()), m = (read<int>()), q = (read<int>());
  G[0].init(), G[1].init();
  for (int i = (1); i <= (n); ++i) w[i] = (read<int>());
  for (int i = (1); i <= (m); ++i) {
    int from = (read<int>()), to = (read<int>());
    G[0].add(from, to), G[0].add(to, from);
  }
  p_cnt = n, dfs1(1, 0, -1), dfs2(1, 0);
  fill(dfn, dfn + p_cnt + 1, 0), dfs_clock = 0;
  dfs3(1, 1);
  for (int i = (1); i <= (p_cnt); ++i) {
    if (!isf[i])
      SEG::update(1, 1, p_cnt, dfn[i], w[i]);
    else
      SEG::update(1, 1, p_cnt, dfn[i], *S[i].begin());
  }
  while (q--) {
    char opt = getchar();
    while (opt != 'A' && opt != 'C') opt = getchar();
    if (opt == 'C') {
      int x = (read<int>()), v = (read<int>());
      if (fa[x]) S[fa[x]].erase(S[fa[x]].find(w[x]));
      w[x] = v, SEG::update(1, 1, p_cnt, dfn[x], v);
      if (fa[x]) {
        S[fa[x]].insert(v);
        SEG::update(1, 1, p_cnt, dfn[fa[x]], *S[fa[x]].begin());
      }
    } else {
      int x = (read<int>()), y = (read<int>());
      printf("%d\n", query_range(x, y));
    }
  }
  return 0;
}