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>
#include <bits/stdc++.h>
using namespace std;
int n, m, q, val[100010], cnt, tot, p[100010], a[200010], nxt[200010],
    w[200010], low[200010];
int top, st[200010], rec, point, father[200010];
bool mak[200010];
multiset<int> s[100010];
void add(int x, int y) {
  tot++;
  a[tot] = y;
  nxt[tot] = p[x];
  p[x] = tot;
}
int rev(int i) { return (i & 1) ? (i + 1) : (i - 1); }
int find(int x) {
  if (father[x] == x) return father[x];
  father[x] = find(father[x]);
  return father[x];
}
void merge(int x, int y) {
  int r1, r2;
  r1 = find(x);
  r2 = find(y);
  if (r1 != r2) father[r1] = r2;
}
namespace Tree {
int p[200010], a[400010], nxt[400010], top[200010], size[200010], son[200010],
    fa[200010];
int w[200010], cnt, tot, num[200010], Min[800010], deep[200010], val[200010], N;
multiset<int>::iterator it;
void add(int x, int y) {
  tot++;
  a[tot] = y;
  nxt[tot] = p[x];
  p[x] = tot;
}
void dfs(int u) {
  deep[u] = deep[fa[u]] + 1;
  size[u] = 1;
  son[u] = 0;
  for (int i = p[u]; i != 0; i = nxt[i])
    if (a[i] != fa[u]) {
      fa[a[i]] = u;
      dfs(a[i]);
      size[u] += size[a[i]];
      if (size[a[i]] > size[son[u]]) son[u] = a[i];
    }
}
void dfs_again(int u, int tp) {
  top[u] = tp;
  w[u] = ++cnt;
  num[cnt] = u;
  if (son[u] != 0) dfs_again(son[u], tp);
  for (int i = p[u]; i != 0; i = nxt[i])
    if (a[i] != fa[u] && a[i] != son[u]) dfs_again(a[i], a[i]);
}
void update(int i) { Min[i] = min(Min[i << 1], Min[(i << 1) + 1]); }
void build(int i, int l, int r) {
  if (l == r) {
    Min[i] = val[num[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build((i << 1) + 1, mid + 1, r);
  update(i);
}
void BuildTree(int point) {
  N = point;
  dfs(1);
  dfs_again(1, 1);
  for (int i = 1; i <= n; i++)
    if (fa[i] > n) s[fa[i] - n].insert(val[i]);
  for (int i = n + 1; i <= N; i++) {
    it = s[i - n].begin();
    val[i] = (*it);
  }
  build(1, 1, N);
}
int ask(int i, int l, int r, int left, int right) {
  if (left <= l && right >= r) return Min[i];
  int mid = (l + r) >> 1, ans = 0x7fffffff;
  if (left <= mid) ans = min(ans, ask(i << 1, l, mid, left, right));
  if (right > mid) ans = min(ans, ask((i << 1) + 1, mid + 1, r, left, right));
  return ans;
}
void change(int i, int l, int r, int x, int v) {
  if (l == r) {
    Min[i] = v;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    change(i << 1, l, mid, x, v);
  else
    change((i << 1) + 1, mid + 1, r, x, v);
  update(i);
}
int Query(int x, int y) {
  int ans = 0x7fffffff;
  while (top[x] != top[y]) {
    if (deep[top[x]] < deep[top[y]]) swap(x, y);
    ans = min(ans, ask(1, 1, N, w[top[x]], w[x]));
    x = fa[top[x]];
  }
  if (deep[x] > deep[y]) swap(x, y);
  ans = min(ans, ask(1, 1, N, w[x], w[y]));
  if (x > n) ans = min(ans, val[fa[x]]);
  return ans;
}
void Change(int x, int y) {
  int pos = fa[x] - n;
  if (pos > 0) {
    it = s[pos].find(val[x]);
    s[pos].erase(it);
    s[pos].insert(y);
    it = s[pos].begin();
    val[fa[x]] = (*it);
    change(1, 1, N, w[fa[x]], val[fa[x]]);
  }
  change(1, 1, N, w[x], y);
  val[x] = y;
}
void print(int N) {
  for (int i = 1; i <= N; i++)
    for (int j = p[i]; j != 0; j = nxt[j]) printf("%d %d\n", i, a[j]);
}
}  // namespace Tree
void Tarjan(int u, int fa, int rt) {
  w[u] = low[u] = ++cnt;
  st[++top] = u;
  for (int i = p[u]; i != 0; i = nxt[i])
    if (w[a[i]] == 0) {
      if (u == 1) ++rec;
      Tarjan(a[i], u, rt);
      low[u] = min(low[u], low[a[i]]);
      if (low[a[i]] >= w[u]) {
        int v;
        mak[u] = true;
        ++point;
        do {
          v = st[top--];
          Tree::add(v, point);
          Tree::add(point, v);
          merge(point, v);
        } while (v != a[i]);
        Tree::add(u, point);
        Tree::add(point, u);
        merge(point, u);
      }
    } else if (a[i] != fa)
      low[u] = min(low[u], w[a[i]]);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  point = n;
  Tarjan(1, 0, 1);
  for (int i = 1; i <= n; i++)
    if (mak[i] == true)
      for (int j = p[i]; j != 0; j = nxt[j])
        if (mak[a[j]] == true && find(i) != find(a[j])) {
          ++point;
          Tree::add(point, i);
          Tree::add(i, point);
          Tree::add(point, a[j]);
          Tree::add(a[j], point);
        }
  for (int i = 1; i <= n; i++) Tree::val[i] = val[i];
  Tree::BuildTree(point);
  for (int i = 1; i <= q; i++) {
    char c = getchar();
    int x, y;
    while (c != 'A' && c != 'C') c = getchar();
    scanf("%d%d", &x, &y);
    if (c == 'A')
      printf("%d\n", Tree::Query(x, y));
    else
      Tree::Change(x, y);
  }
  return 0;
}
