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;
inline int read() {
  register int x(0), f(1);
  register char c(getchar());
  while (c > '9' || c < '0') f = c == '-' ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return f * x;
}
const int N = 410000;
struct Edge {
  struct edge {
    int to, next;
  } e[N];
  int head[N], tot;
  void add(int x, int y) {
    e[++tot].next = head[x];
    e[tot].to = y;
    head[x] = tot;
  }
} E[2];
int n, m, Q, w[N], BCC, dfn[N], low[N], t, sta[N], Top;
void ADD(int u) {
  E[1].add(u, BCC);
  E[1].add(BCC, u);
}
void pre1(int u, int fa) {
  low[u] = dfn[u] = ++t;
  sta[++Top] = u;
  for (int i = E[0].head[u]; i; i = E[0].e[i].next) {
    int v = E[0].e[i].to;
    if (v != fa) {
      if (!dfn[v]) {
        pre1(v, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          BCC++;
          ADD(u);
          while (sta[Top] != v) ADD(sta[Top--]);
          ADD(sta[Top--]);
        }
      } else
        low[u] = min(low[u], dfn[v]);
    }
  }
}
multiset<int> s[N];
multiset<int>::iterator it;
int Fa[N], siz[N], cnt, deep[N], son[N], top[N], seg[N], a[N];
void pre2(int u, int fa) {
  Fa[u] = fa;
  deep[u] = deep[fa] + 1;
  siz[u] = 1;
  for (int i = E[1].head[u]; i; i = E[1].e[i].next) {
    int v = E[1].e[i].to;
    if (v == fa) continue;
    pre2(v, u);
    if (u > n) s[u].insert(w[v]);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
  if (u > n) w[u] = *s[u].begin();
}
void pre3(int u, int topnow) {
  top[u] = topnow;
  a[++cnt] = w[u];
  seg[u] = cnt;
  if (son[u]) pre3(son[u], topnow);
  for (int i = E[1].head[u]; i; i = E[1].e[i].next) {
    int v = E[1].e[i].to;
    if (v != Fa[u] && v != son[u]) pre3(v, v);
  }
}
int mina[N << 2];
void up(int id) { mina[id] = min(mina[id << 1], mina[id << 1 | 1]); }
void build(int l, int r, int id) {
  if (l == r) {
    mina[id] = a[l];
    return;
  }
  build(l, ((l + r) >> 1), id << 1);
  build(((l + r) >> 1) + 1, r, id << 1 | 1);
  up(id);
}
void change(int l, int r, int x, int z, int id) {
  if (l == r) {
    mina[id] = z;
    return;
  }
  if (x <= ((l + r) >> 1))
    change(l, ((l + r) >> 1), x, z, id << 1);
  else
    change(((l + r) >> 1) + 1, r, x, z, id << 1 | 1);
  up(id);
}
int query(int l, int r, int x, int y, int id) {
  if (l >= x && r <= y) return mina[id];
  int ans = 2147483647;
  if (x <= ((l + r) >> 1))
    ans = min(ans, query(l, ((l + r) >> 1), x, y, id << 1));
  if (y > ((l + r) >> 1))
    ans = min(ans, query(((l + r) >> 1) + 1, r, x, y, id << 1 | 1));
  return ans;
}
void Query(int x, int y) {
  int ans = 2147483647;
  while (top[x] != top[y]) {
    if (deep[top[x]] < deep[top[y]]) swap(x, y);
    ans = min(ans, query(1, cnt, seg[top[x]], seg[x], 1));
    x = Fa[top[x]];
  }
  if (deep[x] < deep[y]) swap(x, y);
  ans = min(ans, query(1, cnt, seg[y], seg[x], 1));
  if (y > n) ans = min(ans, query(1, cnt, seg[Fa[y]], seg[Fa[y]], 1));
  cout << ans << '\n';
}
void Change(int x, int y) {
  if (Fa[x]) {
    it = s[Fa[x]].lower_bound(w[x]);
    s[Fa[x]].erase(it);
  }
  w[x] = y;
  change(1, cnt, seg[x], w[x], 1);
  if (Fa[x]) {
    s[Fa[x]].insert(w[x]);
    change(1, cnt, seg[Fa[x]], *s[Fa[x]].begin(), 1);
  }
}
int main() {
  register int i;
  BCC = n = read();
  m = read();
  Q = read();
  for (i = 1; i <= n; i++) w[i] = read();
  for (i = 1; i <= m; i++) {
    int x = read(), y = read();
    E[0].add(x, y);
    E[0].add(y, x);
  }
  pre1(1, 0);
  BCC++;
  while (Top) ADD(sta[Top--]);
  pre2(1, 0);
  pre3(1, 1);
  memset(mina, 127, sizeof(mina));
  build(1, cnt, 1);
  while (Q--) {
    char opt;
    cin >> opt;
    int x = read(), y = read();
    if (opt == 'A')
      Query(x, y);
    else
      Change(x, y);
  }
  return 0;
}
