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>
const int MAXN = 200010;
const int MAXM = 200010;
const int INF = 0x3f3f3f3f;
int n, m, q, totn, a[MAXN];
int dfn[MAXN], rev[MAXN], cnt, fa[MAXN], siz[MAXN], son[MAXN], dep[MAXN],
    top[MAXN];
namespace sgt {
struct node {
  int l, r, minn;
} t[MAXN << 2];
inline void pushUp(int k) {
  t[k].minn = std::min(t[k << 1].minn, t[k << 1 | 1].minn);
}
void build(int l, int r, int k) {
  t[k].l = l;
  t[k].r = r;
  if (l == r) {
    t[k].minn = a[rev[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, k << 1);
  build(mid + 1, r, k << 1 | 1);
  pushUp(k);
}
void update(int pos, int val, int k) {
  if (t[k].l == t[k].r) {
    t[k].minn = val;
    return;
  }
  int mid = (t[k].l + t[k].r) >> 1;
  if (pos <= mid)
    update(pos, val, k << 1);
  else
    update(pos, val, k << 1 | 1);
  pushUp(k);
}
int query(int x, int y, int k) {
  if (t[k].l >= x && t[k].r <= y) return t[k].minn;
  int mid = (t[k].l + t[k].r) >> 1, res = INF;
  if (x <= mid) res = std::min(res, query(x, y, k << 1));
  if (y > mid) res = std::min(res, query(x, y, k << 1 | 1));
  return res;
}
}  // namespace sgt
struct Tree {
  struct edge {
    int ne, to;
    edge(int N = 0, int T = 0) : ne(N), to(T) {}
  } e[MAXM];
  int fir[MAXN], num = 0;
  inline void reset() {
    for (int i = 1; i <= n; i++) fir[i] = 0;
    num = 0;
  }
  inline void join(int a, int b) {
    e[++num] = edge(fir[a], b);
    fir[a] = num;
  }
  void dfs1(int u) {
    siz[u] = 1;
    son[u] = 0;
    for (int i = fir[u]; i; i = e[i].ne) {
      int v = e[i].to;
      dep[v] = dep[u] + 1;
      fa[v] = u;
      dfs1(v);
      siz[u] += siz[v];
      if (siz[son[u]] < siz[v]) son[u] = v;
    }
  }
  void dfs2(int u, int tp) {
    rev[dfn[u] = ++cnt] = u;
    top[u] = tp;
    if (son[u]) dfs2(son[u], tp);
    for (int i = fir[u]; i; i = e[i].ne) {
      int v = e[i].to;
      if (v != son[u] && v != fa[u]) dfs2(v, v);
    }
  }
} T;
struct graph {
  struct edge {
    int ne, to;
    edge(int N = 0, int T = 0) : ne(N), to(T) {}
  } e[MAXM];
  int fir[MAXN], num = 0;
  int dfn[MAXN], low[MAXN], cnt, stk[MAXN], top;
  inline void reset() {
    for (int i = 1; i <= n; i++) dfn[i] = fir[i] = 0;
    num = cnt = top = 0;
  }
  inline void join(int a, int b) {
    e[++num] = edge(fir[a], b);
    fir[a] = num;
  }
  void tarjan(int u) {
    dfn[u] = low[u] = ++cnt;
    stk[++top] = u;
    for (int i = fir[u]; i; i = e[i].ne) {
      int v = e[i].to;
      if (!dfn[v]) {
        tarjan(v);
        low[u] = std::min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          int x = 0;
          ++totn;
          T.join(u, totn);
          do {
            x = stk[top];
            T.join(totn, x);
            --top;
          } while (x != v);
        }
      } else
        low[u] = std::min(low[u], dfn[v]);
    }
  }
} G;
std::multiset<int> val[MAXN];
inline int qryPath(int x, int y) {
  int res = INF;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) std::swap(x, y);
    res = std::min(res, sgt::query(dfn[top[x]], dfn[x], 1));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) std::swap(x, y);
  res = std::min(res, sgt::query(dfn[x], dfn[y], 1));
  if (x > n) res = std::min(res, a[fa[x]]);
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G.join(u, v);
    G.join(v, u);
  }
  totn = n;
  G.tarjan(1);
  T.dfs1(1);
  T.dfs2(1, 1);
  for (int i = 1; i <= n; i++)
    if (fa[i]) val[fa[i]].insert(a[i]);
  for (int i = n + 1; i <= totn; i++)
    a[i] = val[i].empty() ? INF : *val[i].begin();
  sgt::build(1, totn, 1);
  while (q--) {
    char opt[3];
    int x, y;
    scanf("%s%d%d", opt + 1, &x, &y);
    if (opt[1] == 'C') {
      if (fa[x]) {
        val[fa[x]].erase(val[fa[x]].find(a[x]));
        val[fa[x]].insert(y);
        a[fa[x]] = *val[fa[x]].begin();
        sgt::update(dfn[fa[x]], a[fa[x]], 1);
      }
      sgt::update(dfn[x], y, 1);
      a[x] = y;
    } else
      printf("%d\n", qryPath(x, y));
  }
  return 0;
}