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, num, tot, tp, cnt, ans, w[200100], head[200100], dfn[200100],
    c[200100], low[200100], sta[200100];
int dfc, sz[200100], d[200100], f[200100], son[200100], top[200100],
    tree[200100], mn[200100 * 4];
vector<int> v[200100];
multiset<int> s[200100];
struct point {
  int fr, to, nxt;
} a[200100 * 2];
void add(int x, int y) {
  a[++tot].fr = x;
  a[tot].to = y;
  a[tot].nxt = head[x];
  head[x] = tot;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++num;
  sta[++tp] = x;
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] == dfn[x]) {
        ++cnt;
        int now;
        do {
          now = sta[tp--];
          add(cnt, now);
          add(now, cnt);
        } while (now != y);
        add(cnt, x);
        add(x, cnt);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
void dfs1(int x, int fa) {
  f[x] = fa;
  d[x] = d[fa] + 1;
  sz[x] = 1;
  for (int i = head[x]; i; i = a[i].nxt) {
    int y = a[i].to;
    if (y == fa) continue;
    dfs1(y, x);
    sz[x] += sz[y];
    if (sz[y] > sz[son[x]]) son[x] = y;
  }
}
void dfs2(int x, int lst) {
  top[x] = lst;
  dfn[x] = ++dfc;
  tree[dfc] = x;
  if (son[x]) dfs2(son[x], lst);
  for (int i = head[x]; i; i = a[i].nxt)
    if (!top[a[i].to]) dfs2(a[i].to, a[i].to);
}
void build(int x, int l, int r) {
  if (l == r) return mn[x] = w[tree[l]], void();
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
}
void modify(int x, int l, int r, int p, int y) {
  if (l == r) return mn[x] = y, void();
  int mid = (l + r) >> 1;
  if (p <= mid)
    modify(x << 1, l, mid, p, y);
  else
    modify(x << 1 | 1, mid + 1, r, p, y);
  mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
}
int query(int x, int l, int r, int L, int R) {
  if (l >= L && r <= R) return mn[x];
  int mid = (l + r) >> 1, ret = 1e9;
  if (L <= mid) ret = min(ret, query(x << 1, l, mid, L, R));
  if (R > mid) ret = min(ret, query(x << 1 | 1, mid + 1, r, L, R));
  return ret;
}
int query(int x, int y, int ret = 1e9) {
  while (top[x] != top[y]) {
    if (d[top[x]] < d[top[y]]) swap(x, y);
    ret = min(ret, query(1, 1, cnt, dfn[top[x]], dfn[x]));
    x = f[top[x]];
  }
  if (d[x] < d[y]) swap(x, y);
  ret = min(ret, query(1, 1, cnt, dfn[y], dfn[x]));
  if (y > n) ret = min(ret, w[f[y]]);
  return ret;
}
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, x, y; i <= m; i++)
    scanf("%d%d", &x, &y), v[x].push_back(y), v[y].push_back(x);
  tarjan(1);
  dfs1(1, 0);
  dfs2(1, 1);
  memset(mn, 0x3f, sizeof(mn));
  for (int i = 1; i <= n; i++) s[f[i]].insert(w[i]);
  for (int i = n + 1; i <= cnt; i++) w[i] = (*s[i].begin());
  build(1, 1, cnt);
  for (int i = 1; i <= q; i++) {
    char ch[4];
    int a, b;
    scanf("%s%d%d", ch + 1, &a, &b);
    if (ch[1] == 'C') {
      if (f[a]) {
        multiset<int>::iterator pos = s[f[a]].find(w[a]);
        s[f[a]].erase(pos);
        s[f[a]].insert(b);
        w[f[a]] = (*s[f[a]].begin());
        modify(1, 1, cnt, dfn[f[a]], (*s[f[a]].begin()));
      }
      w[a] = b;
      modify(1, 1, cnt, dfn[a], w[a]);
    } else
      printf("%d\n", query(a, b));
  }
}