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 inf = 0x3f3f3f3f;
const int MAXN = 200005;
template <typename T>
void read(T &x) {
  T flag = 1;
  char ch = getchar();
  for (; '0' > ch || ch > '9'; ch = getchar())
    if (ch == '-') flag = 1;
  for (x = 0; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= flag;
}
struct segment {
  int mn;
} tr[MAXN << 2];
void add(int x, int l, int r, int p, int v) {
  if (l == r) {
    tr[x].mn = v;
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    add(x << 1, l, mid, p, v);
  else
    add(x << 1 | 1, mid + 1, r, p, v);
  tr[x].mn = min(tr[x << 1].mn, tr[x << 1 | 1].mn);
}
int ask(int p, int l, int r, int x, int y) {
  if (l > y || r < x) return inf;
  if (x <= l && r <= y) return tr[p].mn;
  int mid = (l + r) >> 1;
  return min(ask(p << 1, l, mid, x, y), ask(p << 1 | 1, mid + 1, r, x, y));
}
int val[MAXN], pos[MAXN];
void build(int p, int l, int r) {
  if (l == r) {
    tr[p].mn = val[pos[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  tr[p].mn = min(tr[p << 1].mn, tr[p << 1 | 1].mn);
}
struct node {
  int pre, to;
} edge[MAXN << 1];
int head[MAXN], tot = 1;
int n, m, q, N;
multiset<int> s[MAXN];
int dfn[MAXN], low[MAXN], stk[MAXN], Top, DEP;
int col[MAXN], w[MAXN];
vector<int> vec[MAXN];
void add_edge(int u, int v) {
  edge[++tot] = node{head[u], v};
  head[u] = tot;
}
void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++DEP;
  stk[++Top] = x;
  for (int i = head[x]; i; i = edge[i].pre) {
    int y = edge[i].to;
    if (!dfn[y]) {
      tarjan(y, x);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        N++;
        val[N] = inf;
        int z;
        do {
          z = stk[Top--];
          col[z] = N;
          vec[N].push_back(z);
          vec[z].push_back(N);
        } while (z != y);
        z = x;
        col[z] = N;
        vec[N].push_back(z);
        vec[z].push_back(N);
      }
    } else if (y != fa)
      low[x] = min(low[x], dfn[y]);
  }
}
int Fa[MAXN];
int sz[MAXN], son[MAXN], dep[MAXN];
int num, top[MAXN], zcr[MAXN];
void dfs(int x, int fa) {
  sz[x] = 1;
  for (auto y : vec[x]) {
    if (y == fa) continue;
    s[x].insert(w[y]);
    dep[y] = dep[x] + 1;
    Fa[y] = x;
    dfs(y, x);
    sz[x] += sz[y];
    if (sz[son[x]] < sz[y]) son[x] = y;
  }
  if (x <= n)
    val[x] = w[x];
  else
    val[x] = *s[x].begin();
}
void dfs2(int x, int chain) {
  pos[++num] = x;
  zcr[x] = num;
  top[x] = chain;
  if (son[x]) dfs2(son[x], chain);
  for (auto y : vec[x]) {
    if (y == Fa[x] || y == son[x]) continue;
    dfs2(y, y);
  }
}
int LCA(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = Fa[top[u]];
  }
  return dep[u] < dep[v] ? u : v;
}
int query(int u, int v) {
  int ret = inf;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    ret = min(ret, ask(1, 1, num, zcr[top[u]], zcr[u]));
    u = Fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  ret = min(ret, ask(1, 1, num, zcr[u], zcr[v]));
  return ret;
}
int main() {
  read(n);
  read(m);
  read(q);
  N = n;
  for (int i = 1; i <= n; i++) read(w[i]);
  for (int i = 1; i <= m; i++) {
    int a, b;
    read(a);
    read(b);
    add_edge(a, b);
    add_edge(b, a);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) {
      tarjan(i, 0);
    }
  }
  dfs(1, 0);
  dfs2(1, 1);
  build(1, 1, num);
  char opt[5];
  while (q--) {
    int a, b;
    scanf("%s", opt + 1);
    read(a);
    read(b);
    if (opt[1] == 'C') {
      if (Fa[a]) s[Fa[a]].erase(s[Fa[a]].lower_bound(val[a]));
      val[a] = b;
      if (Fa[a]) s[Fa[a]].insert(val[a]);
      if (Fa[a]) val[Fa[a]] = *s[Fa[a]].begin();
      add(1, 1, num, zcr[a], val[a]);
      if (Fa[a]) add(1, 1, num, zcr[Fa[a]], val[Fa[a]]);
    } else {
      int lca = LCA(a, b);
      int ans = query(a, b);
      if (lca > n && Fa[lca]) {
        ans = min(ans, val[Fa[lca]]);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}