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>
clock_t t = clock();
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T& x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T& x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T& t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
char __sr[1 << 21], __z[20];
int __C = -1, __Z = 0;
inline void __Ot() { fwrite(__sr, 1, __C + 1, stdout), __C = -1; }
inline void print(register int x) {
  if (__C > 1 << 20) __Ot();
  if (x < 0) __sr[++__C] = '-', x = -x;
  while (__z[++__Z] = x % 10 + 48, x /= 10)
    ;
  while (__sr[++__C] = __z[__Z], --__Z)
    ;
  __sr[++__C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n, m, Q, N;
int val[201001];
multiset<int> s[201001];
struct hh {
  int t, nxt;
} edge[201001 << 1];
int head[201001], ecnt;
void make_edge(int f, int t) {
  edge[++ecnt] = (hh){t, head[f]};
  head[f] = ecnt;
  edge[++ecnt] = (hh){f, head[t]};
  head[t] = ecnt;
}
namespace BuildTree {
struct hh {
  int t, nxt;
} edge[201001 << 1];
int head[201001], ecnt;
void make_edge(int f, int t) {
  edge[++ecnt] = (hh){t, head[f]};
  head[f] = ecnt;
  edge[++ecnt] = (hh){f, head[t]};
  head[t] = ecnt;
}
int dfn[201001], low[201001], cnt;
stack<int> s;
bool in[201001];
void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++cnt;
  in[x] = 1;
  s.push(x);
  for (int i = head[x]; i; i = edge[i].nxt)
    if (edge[i].t != fa) {
      if (!dfn[edge[i].t]) {
        tarjan(edge[i].t, x), chkmin(low[x], low[edge[i].t]);
        if (low[edge[i].t] >= dfn[x]) {
          ++N;
          ::make_edge(x, N);
          int y;
          do {
            y = s.top();
            s.pop();
            in[y] = 0;
            ::make_edge(y, N);
          } while (y != edge[i].t);
        }
      } else
        chkmin(low[x], dfn[edge[i].t]);
    }
}
void init() {
  read(n, m, Q);
  N = n;
  for (int i = (1); i <= (n); i++) read(val[i]);
  int x, y;
  for (int i = (1); i <= (m); i++) read(x, y), make_edge(x, y);
  tarjan(1, 0);
}
}  // namespace BuildTree
int dfn[201001], pre[201001], top[201001], fa[201001], dep[201001],
    size[201001], son[201001], cnt;
void dfs1(int x, int fa) {
  dep[x] = dep[::fa[x] = fa] + 1;
  size[x] = 1;
  if (x <= n && x != 1) s[fa].insert(val[x]);
  for (int i = head[x]; i; i = edge[i].nxt)
    if (edge[i].t != fa) {
      dfs1(edge[i].t, x);
      size[x] += size[edge[i].t];
      if (size[edge[i].t] > size[son[x]]) son[x] = edge[i].t;
    }
  if (x > n) val[x] = *s[x].begin();
}
void dfs2(int x, int fa, int tp) {
  top[pre[dfn[x] = ++cnt] = x] = tp;
  if (son[x]) dfs2(son[x], x, tp);
  for (int i = head[x]; i; i = edge[i].nxt)
    if (edge[i].t != fa && edge[i].t != son[x]) dfs2(edge[i].t, x, edge[i].t);
}
int mn[201001 << 2];
void pushup(int k) { mn[k] = min(mn[k << 1], mn[k << 1 | 1]); }
void modify(int k, int l, int r, int x, int y) {
  if (l == r) return void(mn[k] = y);
  int mid = (l + r) >> 1;
  if (x <= mid)
    modify(k << 1, l, mid, x, y);
  else
    modify(k << 1 | 1, mid + 1, r, x, y);
  pushup(k);
}
int query(int k, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[k];
  int mid = (l + r) >> 1, ret = 1e9;
  if (x <= mid) chkmin(ret, query(k << 1, l, mid, x, y));
  if (y > mid) chkmin(ret, query(k << 1 | 1, mid + 1, r, x, y));
  return ret;
}
void modify(int x, int w) {
  if (x == 1) return void(modify(1, 1, N, dfn[x], val[x] = w));
  s[fa[x]].erase(s[fa[x]].find(val[x]));
  s[fa[x]].insert(w);
  val[x] = w;
  modify(1, 1, N, dfn[x], w);
  modify(1, 1, N, dfn[fa[x]], *s[fa[x]].begin());
}
int query(int x, int y) {
  int ret = 1e9;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    chkmin(ret, query(1, 1, N, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  chkmin(ret, query(1, 1, N, dfn[x], dfn[y]));
  if (x != 1 && x > n) chkmin(ret, val[fa[x]]);
  return ret;
}
int main() {
  file();
  BuildTree::init();
  dfs1(1, 0);
  dfs2(1, 0, 1);
  for (int i = (1); i <= (N); i++) modify(1, 1, N, dfn[i], val[i]);
  char c;
  int x, y;
  while (Q--) {
    c = getchar();
    while (c != 'C' && c != 'A') c = getchar();
    read(x, y);
    if (c == 'C')
      modify(x, y);
    else
      printf("%d\n", query(x, y));
  }
  return 0;
}