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 = 400010;
const int inf = 0x3f3f3f3f;
int n, m, q;
int a[N];
int cnt = 1, head[N];
struct Edge {
  int to, next;
} e[N << 1];
void ade(int u, int v) {
  e[++cnt] = (Edge){v, head[u]};
  head[u] = cnt;
}
int fang;
vector<int> g[N];
namespace Tarjan {
int dfn[N], low[N], dfsclk;
int tp, sta[N];
void dfs(int x) {
  dfn[x] = low[x] = ++dfsclk;
  sta[++tp] = x;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (!dfn[to]) {
      dfs(to);
      low[x] = min(low[x], low[to]);
      if (low[to] >= dfn[x]) {
        ++fang;
        g[fang].push_back(x);
        g[x].push_back(fang);
        int tmp;
        do {
          tmp = sta[tp--];
          g[fang].push_back(tmp);
          g[tmp].push_back(fang);
        } while (tmp != to);
      }
    } else
      low[x] = min(low[x], dfn[to]);
  }
}
}  // namespace Tarjan
namespace seg {
int mn[N << 2];
inline void pushup(int p) { mn[p] = min(mn[p << 1], mn[p << 1 | 1]); }
void update(int p, int l, int r, int pos, int val) {
  if (l == r) {
    mn[p] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(p << 1, l, mid, pos, val);
  else
    update(p << 1 | 1, mid + 1, r, pos, val);
  pushup(p);
}
int query(int p, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return mn[p];
  int mid = (l + r) >> 1;
  if (qr <= mid)
    return query(p << 1, l, mid, ql, qr);
  else if (ql > mid)
    return query(p << 1 | 1, mid + 1, r, ql, qr);
  else
    return min(query(p << 1, l, mid, ql, mid),
               query(p << 1 | 1, mid + 1, r, mid + 1, qr));
}
}  // namespace seg
multiset<int> s[N];
namespace tcc {
int clk, d[N], fa[N], top[N], size[N], son[N], dfn[N], rev[N];
void dfs1(int x, int f) {
  d[x] = d[f] + 1;
  fa[x] = f;
  size[x] = 1;
  if (x <= n && f) s[f].insert(a[x]);
  for (int i = 0; i < g[x].size(); i++) {
    int to = g[x][i];
    if (to == f) continue;
    dfs1(to, x);
    size[x] += size[to];
    if (size[to] > size[son[x]]) son[x] = to;
  }
}
void dfs2(int x, int tp) {
  dfn[x] = ++clk;
  rev[clk] = x;
  top[x] = tp;
  if (son[x]) dfs2(son[x], tp);
  for (int i = 0; i < g[x].size(); i++) {
    int to = g[x][i];
    if (to == fa[x] || to == son[x]) continue;
    dfs2(to, to);
  }
}
void update(int x, int y) {
  if (fa[x]) {
    s[fa[x]].erase(s[fa[x]].find(a[x]));
    s[fa[x]].insert(y);
    seg::update(1, 1, fang, dfn[fa[x]], *s[fa[x]].begin());
  }
  a[x] = y;
  seg::update(1, 1, fang, dfn[x], a[x]);
}
int query(int x, int y) {
  int ret = inf;
  while (top[x] != top[y]) {
    if (d[top[x]] < d[top[y]]) swap(x, y);
    ret = min(ret, seg::query(1, 1, fang, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (d[x] < d[y]) swap(x, y);
  ret = min(ret, seg::query(1, 1, fang, dfn[y], dfn[x]));
  if (y > n) ret = min(ret, a[fa[y]]);
  return ret;
}
}  // namespace tcc
namespace lyr {
void work() {
  scanf("%d%d%d", &n, &m, &q);
  fang = n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ade(u, v);
    ade(v, u);
  }
  Tarjan::dfs(1);
  tcc::dfs1(1, 0);
  tcc::dfs2(1, 1);
  for (int i = 1; i <= n; i++) seg::update(1, 1, fang, tcc::dfn[i], a[i]);
  for (int i = n + 1; i <= fang; i++)
    seg::update(1, 1, fang, tcc::dfn[i], *s[i].begin());
  for (int i = 1; i <= q; i++) {
    char ch[5];
    int a, b;
    scanf("%s", ch + 1);
    scanf("%d%d", &a, &b);
    if (ch[1] == 'C')
      tcc::update(a, b);
    else
      printf("%d\n", tcc::query(a, b));
  }
}
}  // namespace lyr
int main() {
  lyr::work();
  return 0;
}