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;
stack<int> stk;
multiset<int> st[200010];
char op[5];
int n, minn[800010], fa[200010], dep[200010], top[200010], sz[200010],
    son[200010], id[200010], pos[200010], dfn[100010], low[100010], a[200010],
    head[100010], to[200010], nxt[200010], head2[200010], to2[200010],
    nxt2[200010], tot, tot2, bcc_tot;
void addedge(int u, int v) {
  to[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
}
void addedge2(int u, int v) {
  to2[++tot2] = v;
  nxt2[tot2] = head2[u];
  head2[u] = tot2;
}
void dfs(int u, int f) {
  dfn[u] = low[u] = ++tot;
  stk.push(u);
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (!dfn[v]) {
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        bcc_tot++;
        addedge2(u, n + bcc_tot);
        fa[n + bcc_tot] = u;
        for (int w = 0; w != v;) {
          w = stk.top();
          stk.pop();
          addedge2(n + bcc_tot, w);
          fa[w] = n + bcc_tot;
        }
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
void dfs2(int u) {
  sz[u] = 1;
  for (int i = head2[u]; i; i = nxt2[i]) {
    int v = to2[i];
    if (v == fa[u]) continue;
    dep[v] = dep[u] + 1;
    dfs2(v);
    sz[u] += sz[v];
    if (sz[son[u]] < sz[v]) son[u] = v;
  }
}
void dfs3(int u) {
  id[u] = ++tot;
  pos[tot] = u;
  if (u == son[fa[u]])
    top[u] = top[fa[u]];
  else
    top[u] = u;
  if (son[u]) dfs3(son[u]);
  for (int i = head2[u]; i; i = nxt2[i]) {
    int v = to2[i];
    if (v != fa[u] && v != son[u]) dfs3(v);
  }
}
void build(int rt, int l, int r) {
  if (l == r) return minn[rt] = a[pos[l]], void();
  int mid = (l + r) / 2;
  build(rt * 2, l, mid);
  build(rt * 2 + 1, mid + 1, r);
  minn[rt] = min(minn[rt * 2], minn[rt * 2 + 1]);
}
void update(int rt, int l, int r, int x, int y) {
  if (l == r) return minn[rt] = y, void();
  int mid = (l + r) / 2;
  if (x <= mid)
    update(rt * 2, l, mid, x, y);
  else
    update(rt * 2 + 1, mid + 1, r, x, y);
  minn[rt] = min(minn[rt * 2], minn[rt * 2 + 1]);
}
int query(int rt, int l, int r, int x, int y) {
  if (l > y || r < x) return 1e9;
  if (x <= l && r <= y) return minn[rt];
  int mid = (l + r) / 2;
  return min(query(rt * 2, l, mid, x, y), query(rt * 2 + 1, mid + 1, r, x, y));
}
int main() {
  int m, q, u, v;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  tot = 0;
  dfs(1, 0);
  for (int i = n + 1; i <= n + bcc_tot; i++) {
    a[i] = 1e9;
    for (int j = head2[i]; j; j = nxt2[j])
      st[i].insert(a[to2[j]]), a[i] = min(a[i], a[to2[j]]);
  }
  tot = 0;
  dfs2(1);
  dfs3(1);
  build(1, 1, n + bcc_tot);
  while (q--) {
    scanf("%s%d%d", op, &u, &v);
    if (op[0] == 'C') {
      update(1, 1, n + bcc_tot, id[u], v);
      if (fa[u]) {
        st[fa[u]].erase(st[fa[u]].find(a[u]));
        st[fa[u]].insert(v);
        a[fa[u]] = *st[fa[u]].begin();
        update(1, 1, n + bcc_tot, id[fa[u]], a[fa[u]]);
      }
      a[u] = v;
    } else {
      int ans = 1e9;
      while (top[u] != top[v]) {
        if (dep[top[u]] < dep[top[v]]) swap(u, v);
        ans = min(ans, query(1, 1, n + bcc_tot, id[top[u]], id[u]));
        u = fa[top[u]];
      }
      if (dep[u] > dep[v]) swap(u, v);
      ans = min(ans, query(1, 1, n + bcc_tot, id[u], id[v]));
      if (u > n) ans = min(ans, query(1, 1, n + bcc_tot, id[fa[u]], id[fa[u]]));
      printf("%d\n", ans);
    }
  }
  return 0;
}