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 = 200000 + 10;
const int INF = 0x3f3f3f3f;
struct Gragh {
  struct Edge {
    int v, next;
    Edge() {}
    Edge(int v, int next) : v(v), next(next) {}
  } e[maxn << 1];
  int fir[maxn], ecnt;
  Gragh() {
    memset(fir, 0, sizeof fir);
    ecnt = 0;
  }
  void add(int u, int v) {
    e[++ecnt] = Edge(v, fir[u]);
    fir[u] = ecnt;
  }
  void ins(int u, int v) {
    add(u, v);
    add(v, u);
  }
};
struct SegmentTree {
  int mi[maxn << 2];
  void build(int, int, int);
  void update(int, int, int, int, int);
  int query(int, int, int, int, int);
};
void tarjan(int, int);
void dfs1(int);
void dfs2(int);
int n, m, q, N;
int w[maxn], dfn[maxn], low[maxn], Index;
int stk[maxn], stop;
int top[maxn], size[maxn], fa[maxn], son[maxn], dep[maxn], p[maxn], fp[maxn],
    tn;
SegmentTree sg;
Gragh G, T;
std::multiset<int> ms[maxn];
int main() {
  std::cin >> n >> m >> q;
  N = n;
  for (int i = 1; i <= n; i++) std::cin >> w[i];
  for (int u, v, i = 1; i <= m; i++) {
    std::cin >> u >> v;
    G.ins(u, v);
  }
  tarjan(1, 0);
  dfs1(1);
  top[1] = 1;
  dfs2(1);
  sg.build(1, N, 1);
  char op;
  int a, b, ans;
  while (q--) {
    std::cin >> op >> a >> b;
    if (op == 'C') {
      sg.update(1, N, 1, p[a], b);
      if (fa[a]) {
        ms[fa[a]].erase(ms[fa[a]].find(w[a]));
        ms[fa[a]].insert(b);
        sg.update(1, N, 1, p[fa[a]], *ms[fa[a]].begin());
      }
      w[a] = b;
    } else {
      ans = INF;
      while (top[a] != top[b]) {
        if (dep[top[a]] < dep[top[b]]) std::swap(a, b);
        ans = std::min(ans, sg.query(1, N, 1, p[top[a]], p[a]));
        a = fa[top[a]];
      }
      if (dep[a] > dep[b]) std::swap(a, b);
      ans = std::min(ans, sg.query(1, N, 1, p[a], p[b]));
      if (fa[a] && fa[a] <= n) ans = std::min(ans, w[fa[a]]);
      std::cout << ans << std::endl;
    }
  }
}
void tarjan(int u, int f) {
  dfn[u] = low[u] = ++Index;
  for (int v, i = G.fir[u]; i; i = G.e[i].next) {
    v = G.e[i].v;
    if (v == f) continue;
    if (!dfn[v]) {
      stk[++stop] = v;
      tarjan(v, u);
      low[u] = std::min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        int p;
        N++;
        do {
          p = stk[stop--];
          T.ins(p, N);
        } while (p != v);
        T.ins(u, N);
      }
    } else
      low[u] = std::min(low[u], dfn[v]);
  }
}
void dfs1(int u) {
  size[u] = 1;
  for (int v, i = T.fir[u]; i; i = T.e[i].next) {
    v = T.e[i].v;
    if (v == fa[u]) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    dfs1(v);
    size[u] += size[v];
    if (size[son[u]] < size[v]) son[u] = v;
    if (u > n) ms[u].insert(w[v]);
  }
}
void dfs2(int u) {
  p[u] = ++tn;
  fp[tn] = u;
  if (son[u]) {
    top[son[u]] = top[u];
    dfs2(son[u]);
  }
  for (int v, i = T.fir[u]; i; i = T.e[i].next) {
    v = T.e[i].v;
    if (v == son[u] || v == fa[u]) continue;
    top[v] = v;
    dfs2(v);
  }
}
void SegmentTree::build(int l, int r, int x) {
  if (l == r) {
    if (fp[l] <= n)
      mi[x] = w[fp[l]];
    else
      mi[x] = *ms[fp[l]].begin();
  } else {
    int mid = (l + r) >> 1;
    build(l, mid, x << 1);
    build(mid + 1, r, x << 1 | 1);
    mi[x] = std::min(mi[x << 1], mi[x << 1 | 1]);
  }
}
void SegmentTree::update(int l, int r, int x, int pos, int val) {
  if (l == r)
    mi[x] = val;
  else {
    int mid = (l + r) >> 1;
    if (pos <= mid)
      update(l, mid, x << 1, pos, val);
    else
      update(mid + 1, r, x << 1 | 1, pos, val);
    mi[x] = std::min(mi[x << 1], mi[x << 1 | 1]);
  }
}
int SegmentTree::query(int l, int r, int x, int ql, int qr) {
  if (ql <= l && r <= qr)
    return mi[x];
  else {
    int mid = (l + r) >> 1, ret = INF;
    if (ql <= mid) ret = std::min(ret, query(l, mid, x << 1, ql, qr));
    if (qr > mid) ret = std::min(ret, query(mid + 1, r, x << 1 | 1, ql, qr));
    return ret;
  }
}