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 Maxn = 200005;
inline int read() {
  char c;
  int rec = 0;
  while ((c = getchar()) < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9') rec = rec * 10 + c - '0', c = getchar();
  return rec;
}
int n, m, Q, val[Maxn];
struct Graph {
  struct Branch {
    int next, to;
  } branch[Maxn << 1];
  int h[Maxn], cnt;
  inline void add(int x, int y) {
    branch[++cnt].to = y;
    branch[cnt].next = h[x];
    h[x] = cnt;
    return;
  }
} G, T;
int Bcc, dfn[Maxn], low[Maxn], idx, S[Maxn], Top;
void Tarjan(int v) {
  dfn[v] = low[v] = ++idx;
  S[++Top] = v;
  for (int i = G.h[v]; i; i = G.branch[i].next) {
    if (!dfn[G.branch[i].to]) {
      Tarjan(G.branch[i].to);
      low[v] = min(low[v], low[G.branch[i].to]);
      if (low[G.branch[i].to] >= dfn[v]) {
        int p = 0;
        ++Bcc;
        T.add(Bcc, v);
        T.add(v, Bcc);
        while (p != G.branch[i].to) {
          p = S[Top--];
          T.add(Bcc, p);
          T.add(p, Bcc);
        }
      }
    } else
      low[v] = min(low[v], dfn[G.branch[i].to]);
  }
  return;
}
multiset<int> U[Maxn];
int D, Minn[Maxn << 3];
int size[Maxn << 1], deep[Maxn << 1];
int top[Maxn << 1], fa[Maxn << 1], son[Maxn << 1];
int id[Maxn << 1], ind;
void Dfs1(int v) {
  size[v] = 1;
  deep[v] = deep[fa[v]] + 1;
  if (v <= n && fa[v]) U[fa[v] - n].insert(val[v]);
  for (int i = T.h[v]; i; i = T.branch[i].next) {
    if (T.branch[i].to == fa[v]) continue;
    fa[T.branch[i].to] = v;
    Dfs1(T.branch[i].to);
    size[v] += size[T.branch[i].to];
    if (size[son[v]] < size[T.branch[i].to]) son[v] = T.branch[i].to;
  }
  return;
}
void Dfs2(int v, int TOP) {
  top[v] = TOP;
  id[v] = ++ind;
  if (son[v]) Dfs2(son[v], TOP);
  for (int i = T.h[v]; i; i = T.branch[i].next)
    if (T.branch[i].to != fa[v] && T.branch[i].to != son[v])
      Dfs2(T.branch[i].to, T.branch[i].to);
  return;
}
inline int Ask(int L, int R) {
  int rec = 0x3f3f3f3f;
  for (int s = L + D - 1, t = R + D + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
    if (~s & 1) rec = min(rec, Minn[s ^ 1]);
    if (t & 1) rec = min(rec, Minn[t ^ 1]);
  }
  return rec;
}
int main() {
  n = read();
  m = read();
  Q = read();
  for (int i = 1; i <= n; ++i) val[i] = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    G.add(x, y);
    G.add(y, x);
  }
  char ch;
  Bcc = n;
  Tarjan(1);
  Dfs1(1);
  Dfs2(1, 1);
  D = 1;
  while (D <= Bcc) D <<= 1;
  memset(Minn, 0x3f, sizeof(Minn));
  for (int i = 1; i <= n; ++i) Minn[D + id[i]] = val[i];
  for (int i = n + 1; i <= Bcc; ++i) Minn[D + id[i]] = *U[i - n].begin();
  for (int i = D; i; --i) Minn[i] = min(Minn[i << 1], Minn[i << 1 | 1]);
  for (int i = 1; i <= Q; ++i) {
    while ((ch = getchar()) != 'A' && ch != 'C')
      ;
    int x = read(), y = read();
    if (ch == 'A') {
      int Ans = 0x3f3f3f3f;
      while (top[x] != top[y]) {
        if (deep[top[x]] < deep[top[y]]) swap(x, y);
        Ans = min(Ans, Ask(id[top[x]], id[x]));
        x = fa[top[x]];
      }
      if (deep[x] < deep[y]) swap(x, y);
      Ans = min(Ans, Ask(id[y], id[x]));
      if (y > n) Ans = min(Ans, val[fa[y]]);
      cout << Ans << '\n';
    } else {
      int p = fa[x];
      if (p) {
        U[p - n].erase(U[p - n].find(val[x]));
        U[p - n].insert(y);
        int v = id[p] + D;
        Minn[v] = *U[p - n].begin();
        v >>= 1;
        while (v) Minn[v] = min(Minn[v << 1], Minn[v << 1 | 1]), v >>= 1;
      }
      val[x] = y;
      int v = id[x] + D;
      Minn[v] = y;
      v >>= 1;
      while (v) Minn[v] = min(Minn[v << 1], Minn[v << 1 | 1]), v >>= 1;
    }
  }
  return 0;
}