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;
int n, m, q, c, val[200100];
namespace SCT {
int dfn[200100], rev[200100], son[200100], sz[200100], fa[200100], top[200100],
    dep[200100], tot, mn[800100];
vector<int> v[200100];
void ae(int x, int y) { v[x].push_back(y), v[y].push_back(x); }
multiset<int> s[100100];
void dfs1(int x, int Fa) {
  fa[x] = Fa, dep[x] = dep[Fa] + 1, sz[x] = 1;
  for (auto y : v[x]) {
    if (y == Fa) continue;
    dfs1(y, x);
    if (x > n) s[x - n].insert(val[y]);
    sz[x] += sz[y];
    if (sz[y] > sz[son[x]]) son[x] = y;
  }
  if (x > n) val[x] = *s[x - n].begin();
}
void dfs2(int x) {
  dfn[x] = ++tot, rev[tot] = x;
  if (son[x]) top[son[x]] = top[x], dfs2(son[x]);
  for (auto y : v[x])
    if (y != fa[x] && y != son[x]) top[y] = y, dfs2(y);
}
void pushup(int x) { mn[x] = min(mn[x << 1], mn[x << 1 | 1]); }
void build(int x, int l, int r) {
  if (l == r) {
    mn[x] = val[rev[l]];
    return;
  }
  build(x << 1, l, ((l + r) >> 1)), build(x << 1 | 1, ((l + r) >> 1) + 1, r),
      pushup(x);
}
int query(int x, int l, int r, int L, int R) {
  if (l > R || r < L) return 0x3f3f3f3f;
  if (L <= l && r <= R) return mn[x];
  return min(query(x << 1, l, ((l + r) >> 1), L, R),
             query(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R));
}
void update(int x, int l, int r, int P) {
  if (l > P || r < P) return;
  if (l == r) {
    mn[x] = val[rev[P]];
    return;
  }
  update(x << 1, l, ((l + r) >> 1), P),
      update(x << 1 | 1, ((l + r) >> 1) + 1, r, P), pushup(x);
}
void prepare() {
  dfs1(1, 0), top[1] = 1, dfs2(1);
  build(1, 1, c);
}
int ask(int x, int y) {
  int res = 0x3f3f3f3f;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    res = min(res, query(1, 1, c, dfn[top[x]], dfn[x])), x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  res = min(res, query(1, 1, c, dfn[x], dfn[y]));
  if (x > n) res = min(res, val[fa[x]]);
  return res;
}
void modify(int x, int y) {
  if (fa[x]) s[fa[x] - n].erase(s[fa[x] - n].find(val[x]));
  val[x] = y;
  if (fa[x])
    s[fa[x] - n].insert(val[x]), val[fa[x]] = *s[fa[x] - n].begin(),
                                 update(1, 1, c, dfn[fa[x]]);
  update(1, 1, c, dfn[x]);
}
}  // namespace SCT
namespace Graph {
vector<int> v[100100];
int dfn[100100], low[100100], tot;
stack<int> s;
void Tarjan(int x) {
  dfn[x] = low[x] = ++tot, s.push(x);
  for (auto y : v[x]) {
    if (!dfn[y]) {
      Tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        c++;
        while (s.top() != y) SCT::ae(c, s.top()), s.pop();
        SCT::ae(c, s.top()), s.pop();
        SCT::ae(c, x);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
}  // namespace Graph
char s[10];
int main() {
  scanf("%d%d%d", &n, &m, &q), c = n;
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1, x, y; i <= m; i++)
    scanf("%d%d", &x, &y), Graph::v[x].push_back(y), Graph::v[y].push_back(x);
  Graph::Tarjan(1);
  SCT::prepare();
  for (int i = 1, x, y; i <= q; i++) {
    scanf("%s%d%d", s, &x, &y);
    if (s[0] == 'C')
      SCT::modify(x, y);
    else
      printf("%d\n", SCT::ask(x, y));
  }
  return 0;
}