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, n0;
multiset<int> st[200086];
int son[200086], rnk[200086], top[200086], siz[200086], fa[200086], dep[200086];
vector<int> v1[200086], v2[200086];
int dfn[200086], low[200086], cnt;
int sk[200086], Top;
int val[200086];
void dfs(int i) {
  dfn[i] = low[i] = ++cnt, sk[++Top] = i;
  for (int j = 0; j < v1[i].size(); j++) {
    int to = v1[i][j];
    if (!dfn[to]) {
      dfs(to);
      low[i] = min(low[i], low[to]);
      if (dfn[i] == low[to]) {
        v2[++n0].push_back(i), v2[i].push_back(n0);
        while (sk[Top + 1] != to)
          v2[n0].push_back(sk[Top]), v2[sk[Top--]].push_back(n0);
      }
    } else {
      low[i] = min(low[i], dfn[to]);
    }
  }
}
struct Node {
  int sum;
} t[200086 << 2];
inline void up(int x) { t[x].sum = min(t[(x << 1)].sum, t[(x << 1 | 1)].sum); }
void build(int x, int l, int r) {
  if (l == r) {
    t[x].sum = val[rnk[l]];
    return;
  }
  int mid = l + r >> 1;
  build((x << 1), l, mid), build((x << 1 | 1), mid + 1, r);
  up(x);
}
inline void modify(int x, int l, int r, int pos, int d) {
  if (l == r) {
    t[x].sum = d;
    return;
  }
  int mid = l + r >> 1;
  if (mid >= pos)
    modify((x << 1), l, mid, pos, d);
  else
    modify((x << 1 | 1), mid + 1, r, pos, d);
  up(x);
}
inline int query(int x, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) return t[x].sum;
  int mid = l + r >> 1, sum = 1e9;
  if (mid >= ll) sum = min(sum, query((x << 1), l, mid, ll, rr));
  if (mid < rr) sum = min(sum, query((x << 1 | 1), mid + 1, r, ll, rr));
  return sum;
}
void dfs1(int i) {
  son[i] = -1, siz[i] = 1;
  if (i <= n)
    st[fa[i]].insert(val[i]);
  else
    val[i] = 1e9;
  for (int j = 0; j < v2[i].size(); j++) {
    int to = v2[i][j];
    if (!dep[to]) {
      dep[to] = dep[i] + 1, fa[to] = i;
      dfs1(to);
      siz[i] += siz[to];
      if (son[i] == -1 || siz[to] > siz[son[i]]) son[i] = to;
    }
  }
  if (i > n) val[i] = *(st[i].begin());
}
void dfs2(int i, int t) {
  top[i] = t, dfn[i] = ++cnt, rnk[cnt] = i;
  if (son[i] == -1) return;
  dfs2(son[i], t);
  for (int j = 0; j < v2[i].size(); j++) {
    int to = v2[i][j];
    if (to != son[i] && to != fa[i]) dfs2(to, to);
  }
}
inline int Query(int x, int y) {
  int ans = 1e9;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ans = min(ans, query(1, 1, n0, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  ans = min(ans, query(1, 1, n0, dfn[x], dfn[y]));
  if (x > n && fa[x]) ans = min(ans, val[fa[x]]);
  return ans;
}
inline void Modify(int x, int y) {
  modify(1, 1, n0, dfn[x], y);
  st[fa[x]].erase(st[fa[x]].find(val[x])), st[fa[x]].insert(val[x] = y);
  modify(1, 1, n0, dfn[fa[x]], *(st[fa[x]].begin()));
}
int x, y;
char s[5];
int main() {
  scanf("%d%d%d", &n, &m, &q), n0 = n;
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  while (m--) {
    scanf("%d%d", &x, &y);
    v1[x].push_back(y), v1[y].push_back(x);
  }
  dfs(1), cnt = 0;
  dep[n0] = 1, dfs1(n0), dfs2(n0, n0);
  build(1, 1, n0);
  while (q--) {
    scanf("%s%d%d", s, &x, &y);
    if (s[0] == 'C') {
      Modify(x, y);
    } else {
      printf("%d\n", Query(x, y));
    }
  }
}