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;
const int N = 1e5 + 7;
const int inf = 1e9;
int n, m, q, tp, ind, cnt;
int w[N], low[N], stk[N], sz[N << 1], son[N << 1], dep[N << 1], top[N << 1],
    dfn[N << 1], f[N << 1], mn[N << 3];
vector<int> g[N], ve[N << 1];
multiset<int> st[N << 1];
void tarjan(int x) {
  dfn[x] = low[x] = ++ind;
  stk[++tp] = x;
  for (auto to : g[x])
    if (!dfn[to]) {
      tarjan(to);
      low[x] = min(low[x], low[to]);
      if (low[to] < dfn[x]) continue;
      int y;
      ++cnt;
      ve[x].push_back(cnt);
      ve[cnt].push_back(x);
      do y = stk[tp--], ve[y].push_back(cnt), ve[cnt].push_back(y);
      while (y != to);
    } else
      low[x] = min(low[x], dfn[to]);
}
void insert(int p, int id, int val, int l, int r) {
  if (l == r) return mn[p] = val, void();
  const int mid = l + r >> 1;
  if (id <= mid)
    insert(p << 1, id, val, l, mid);
  else
    insert(p << 1 | 1, id, val, mid + 1, r);
  mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
}
int query(int p, int l, int r, int L, int R) {
  if (L >= l && R <= r) return mn[p];
  const int mid = L + R >> 1;
  if (r <= mid) return query(p << 1, l, r, L, mid);
  if (l > mid) return query(p << 1 | 1, l, r, mid + 1, R);
  return min(query(p << 1, l, r, L, mid), query(p << 1 | 1, l, r, mid + 1, R));
}
inline int findlca(int x, int y) {
  while (top[x] ^ top[y])
    if (dep[top[x]] > dep[top[y]])
      x = f[top[x]];
    else
      y = f[top[y]];
  return dep[x] > dep[y] ? y : x;
}
inline int query(int x, int y, int ret = inf) {
  while (top[x] ^ top[y])
    if (dep[top[x]] > dep[top[y]])
      ret = min(ret, query(1, dfn[top[x]], dfn[x], 1, cnt)), x = f[top[x]];
    else
      ret = min(ret, query(1, dfn[top[y]], dfn[y], 1, cnt)), y = f[top[y]];
  return min(ret, query(1, min(dfn[x], dfn[y]), max(dfn[x], dfn[y]), 1, cnt));
}
void dfs1(int x) {
  sz[x] = 1;
  dep[x] = dep[f[x]] + 1;
  for (auto to : ve[x])
    if (to != f[x]) {
      f[to] = x;
      dfs1(to);
      sz[x] += sz[to];
      if (sz[to] > sz[son[x]]) son[x] = to;
    }
}
void dfs2(int x) {
  dfn[x] = ++ind;
  if (!son[x]) return;
  top[son[x]] = top[x];
  dfs2(son[x]);
  for (auto to : ve[x])
    if (to != f[x] && to != son[x]) dfs2(top[to] = to);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  cnt = n;
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (int i = 1, a, b; i <= m; ++i)
    scanf("%d%d", &a, &b), g[a].push_back(b), g[b].push_back(a);
  tarjan(1);
  ind = 0;
  dfs1(1);
  dfs2(top[1] = 1);
  for (int i = 2; i <= n; ++i) st[f[i]].insert(w[i]);
  for (int i = 1; i <= n; ++i) insert(1, dfn[i], w[i], 1, cnt);
  for (int i = n + 1; i <= cnt; ++i) insert(1, dfn[i], *st[i].begin(), 1, cnt);
  for (int i = 1; i <= q; ++i) {
    char ch = getchar();
    while (!isalpha(ch)) ch = getchar();
    int x, y;
    scanf("%d%d", &x, &y);
    if (ch == 'A') {
      int g = findlca(x, y), ret = query(x, y);
      if (g > n) ret = min(ret, w[f[g]]);
      printf("%d\n", ret);
    } else {
      if (x > 1) st[f[x]].erase(st[f[x]].find(w[x]));
      w[x] = y;
      insert(1, dfn[x], w[x], 1, cnt);
      if (x > 1)
        st[f[x]].insert(w[x]), insert(1, dfn[f[x]], *st[f[x]].begin(), 1, cnt);
    }
  }
  return 0;
}