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;
namespace Fast {
template <typename __VariableName>
inline __VariableName read() {
  __VariableName __X = 0, __W = 1;
  char __c = getchar();
  while (__c < '0' || __c > '9') {
    if (__c == '-') __W = -1;
    __c = getchar();
  }
  while (__c >= '0' && __c <= '9') __X = __X * 10 + __c - '0', __c = getchar();
  return __X * __W;
}
template <typename __VariableName>
inline void print(__VariableName __X) {
  if (__X < 0) putchar('-'), __X = -__X;
  if (__X > 9) print(__X / 10);
  putchar(__X % 10 + '0');
}
};  // namespace Fast
using namespace Fast;
struct node {
  int to, next;
};
inline void upmin(int &x, const int &y) {
  if (y < x) x = y;
}
const int N = 100010;
int val[N << 1], n, m, q, tot;
multiset<int> st[N];
namespace TCD {
const int N = 200010;
node e[N << 1];
int h[N], sum = 0;
int fa[N], top[N], hson[N];
int size[N], dep[N];
int pos[N], tid[N], clk = 0;
int mn[N << 2];
void AddEdge(int u, int v) {
  e[++sum].to = v;
  e[sum].next = h[u];
  h[u] = sum;
}
void add_edge(int u, int v) {
  AddEdge(u, v);
  AddEdge(v, u);
}
void dfs1(int u, int la) {
  size[u] = 1;
  int mx = 0;
  for (int tmp = h[u]; tmp; tmp = e[tmp].next) {
    int v = e[tmp].to;
    if (v == la) continue;
    dep[v] = dep[u] + 1;
    dfs1(v, u);
    fa[v] = u;
    size[u] += size[v];
    if (size[v] > mx) mx = size[v], hson[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  tid[pos[u] = ++clk] = u;
  if (hson[u]) dfs2(hson[u], tp);
  for (int tmp = h[u]; tmp; tmp = e[tmp].next)
    if (e[tmp].to != fa[u] && e[tmp].to != hson[u]) dfs2(e[tmp].to, e[tmp].to);
}
inline void maintain(int o) { mn[o] = min(mn[o << 1], mn[o << 1 | 1]); }
void Build(int o, int l, int r) {
  if (l == r) {
    mn[o] = val[tid[l]];
    return;
  }
  int mid = (l + r) / 2;
  Build(o << 1, l, mid);
  Build(o << 1 | 1, mid + 1, r);
  maintain(o);
}
void Modify(int o, int l, int r, int k, int x) {
  if (l == r) {
    mn[o] = x;
    return;
  }
  int mid = (l + r) / 2;
  if (k <= mid)
    Modify(o << 1, l, mid, k, x);
  else
    Modify(o << 1 | 1, mid + 1, r, k, x);
  maintain(o);
}
int Query(int o, int l, int r, int nl, int nr) {
  if (l >= nl && r <= nr) return mn[o];
  int mid = (l + r) / 2, res = 0x7f7f7f7f;
  if (nl <= mid) upmin(res, Query(o << 1, l, mid, nl, nr));
  if (nr > mid) upmin(res, Query(o << 1 | 1, mid + 1, r, nl, nr));
  return res;
}
int PathQuery(int u, int v) {
  int res = 0x7f7f7f7f;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    upmin(res, Query(1, 1, tot, pos[top[u]], pos[u]));
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  upmin(res, Query(1, 1, tot, pos[u], pos[v]));
  if (u > n) upmin(res, val[fa[u]]);
  return res;
}
}  // namespace TCD
namespace Graph {
node e[N << 1];
int h[N], sum = 0;
int dfn[N], low[N], tim = 0;
stack<int> stk;
void add_edge(int u, int v) {
  e[++sum].to = v;
  e[sum].next = h[u];
  h[u] = sum;
}
void Tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  stk.push(u);
  for (int tmp = h[u]; tmp; tmp = e[tmp].next) {
    int v = e[tmp].to;
    if (!dfn[v]) {
      Tarjan(v);
      upmin(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        int o;
        tot++;
        do {
          o = stk.top();
          stk.pop();
          TCD::add_edge(o, tot);
        } while (o != v);
        TCD::add_edge(u, tot);
      }
    } else
      upmin(low[u], dfn[v]);
  }
}
}  // namespace Graph
int main() {
  int x, y;
  scanf("%d%d%d", &n, &m, &q);
  tot = n;
  for (int i = 1; i <= n; i++) val[i] = read<int>();
  for (int i = 1; i <= m; i++) {
    x = read<int>();
    y = read<int>();
    Graph::add_edge(x, y);
    Graph::add_edge(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!Graph::dfn[i]) Graph::Tarjan(i);
  TCD::dfs1(1, 0);
  TCD::dfs2(1, 1);
  for (int i = 2; i <= n; i++) st[TCD::fa[i] - n].insert(val[i]);
  for (int i = n + 1; i <= tot; i++)
    val[i] = st[i - n].empty() ? 0x7f7f7f7f : *st[i - n].begin();
  TCD::Build(1, 1, tot);
  while (q--) {
    char opt = getchar();
    while (opt != 'C' && opt != 'A') opt = getchar();
    x = read<int>();
    y = read<int>();
    if (opt == 'C') {
      TCD::Modify(1, 1, tot, TCD::pos[x], y);
      if (x == 1) {
        val[x] = y;
        continue;
      }
      int o = TCD::fa[x];
      st[o - n].erase(st[o - n].find(val[x]));
      st[o - n].insert(y);
      int minv = *st[o - n].begin();
      if (minv == val[o]) {
        val[x] = y;
        continue;
      }
      TCD::Modify(1, 1, tot, TCD::pos[o], minv);
      val[o] = minv;
      val[x] = y;
    } else
      printf("%d\n", TCD::PathQuery(x, y));
  }
  return 0;
}