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;
template <typename T>
inline void read(T &num) {
  T x = 0, f = 1;
  char ch = getchar();
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch <= '9' && ch >= '0'; ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ '0');
  num = x * f;
}
int n, m, q, P, a[1000005];
int head[1000005], pre[1000005 << 1], to[1000005 << 1], sz;
inline void addedge(int u, int v) {
  pre[++sz] = head[u];
  head[u] = sz;
  to[sz] = v;
  pre[++sz] = head[v];
  head[v] = sz;
  to[sz] = u;
}
int dfn[1000005], rnk[1000005], low[1000005], tme, stk[1000005], Top,
    siz[1000005], top[1000005], son[1000005], fa[1000005], col[1000005],
    d[1000005], rt[1000005];
vector<int> e[1000005];
multiset<int> s[1000005];
void tarjan(int x) {
  dfn[x] = low[x] = ++tme;
  stk[++Top] = x;
  for (int i = head[x]; i; i = pre[i]) {
    int y = to[i];
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] == dfn[x]) {
        int z = 0;
        ++n;
        do {
          z = stk[Top--];
          e[n].push_back(z);
          e[z].push_back(n);
          s[n].insert(a[z]);
          col[z] = n;
        } while (z != y);
        rt[n] = x;
        e[n].push_back(x);
        e[x].push_back(n);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
void dfs(int x) {
  siz[x] = 1;
  for (auto y : e[x]) {
    if (y == fa[x]) continue;
    fa[y] = x;
    d[y] = d[x] + 1;
    dfs(y);
    siz[x] += siz[y];
    if (!son[x] || siz[son[x]] < siz[y]) son[x] = y;
  }
}
void dfs2(int x, int tp) {
  top[x] = tp;
  dfn[x] = ++tme;
  rnk[tme] = x;
  if (son[x]) dfs2(son[x], tp);
  for (auto y : e[x]) {
    if (y == fa[x] || y == son[x]) continue;
    dfs2(y, y);
  }
}
struct segtree {
  int tr[1000005];
  void build(int ind, int l, int r) {
    if (l == r) {
      int x = rnk[l];
      if (x <= P)
        tr[ind] = a[x];
      else
        tr[ind] = (*s[x].begin());
      return;
    }
    int mid = (l + r) >> 1;
    build(ind << 1, l, mid);
    build(ind << 1 | 1, mid + 1, r);
    tr[ind] = min(tr[ind << 1], tr[ind << 1 | 1]);
  }
  void update(int ind, int l, int r, int x, int v) {
    if (l == r) return tr[ind] = v, void();
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(ind << 1, l, mid, x, v);
    else
      update(ind << 1 | 1, mid + 1, r, x, v);
    tr[ind] = min(tr[ind << 1], tr[ind << 1 | 1]);
  }
  int query(int ind, int l, int r, int x, int y) {
    if (x <= l && r <= y) return tr[ind];
    int mid = (l + r) >> 1, ret = 0x3f3f3f3f;
    if (x <= mid) ret = min(ret, query(ind << 1, l, mid, x, y));
    if (mid < y) ret = min(ret, query(ind << 1 | 1, mid + 1, r, x, y));
    return ret;
  }
} T;
int Query(int x, int y) {
  int ret = 0x3f3f3f3f;
  while (top[x] != top[y]) {
    if (d[top[x]] < d[top[y]]) swap(x, y);
    ret = min(ret, T.query(1, 1, n, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (d[x] > d[y]) swap(x, y);
  ret = min(ret, T.query(1, 1, n, dfn[x], dfn[y]));
  if (x > P) ret = min(ret, a[rt[x]]);
  return ret;
}
char ccf[5];
int main() {
  read(n);
  read(m);
  read(q);
  P = n;
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1, u, v; i <= m; i++) {
    read(u);
    read(v);
    addedge(u, v);
  }
  for (int i = 1; i <= P; i++)
    if (!dfn[i]) tarjan(i);
  memset(dfn, 0, sizeof(dfn));
  tme = 0;
  dfs(1);
  dfs2(1, 1);
  T.build(1, 1, n);
  for (int i = 1, x, y; i <= q; i++) {
    scanf("%s", ccf);
    read(x);
    read(y);
    if (ccf[0] == 'C') {
      T.update(1, 1, n, dfn[x], y);
      int z = col[x];
      if (z) {
        s[z].erase(s[z].lower_bound(a[x]));
        s[z].insert(y);
        T.update(1, 1, n, dfn[z], (*s[z].begin()));
      }
      a[x] = y;
    } else {
      printf("%d\n", Query(x, y));
    }
  }
  return 0;
}