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 IO {
const int S = (1 << 20) + 5;
char buf[S], *H, *T;
inline char Get() {
  if (H == T) T = (H = buf) + fread(buf, 1, S, stdin);
  if (H == T) return -1;
  return *H++;
}
inline int read() {
  int x = 0;
  char c = Get();
  while (!isdigit(c)) c = Get();
  while (isdigit(c)) x = x * 10 + c - '0', c = Get();
  return x;
}
char obuf[S], *oS = obuf, *oT = oS + S - 1, c, qu[55];
int qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
  putc('\n');
}
}  // namespace IO
using namespace IO;
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;
struct Edge {
  int to, next;
} e[N << 1];
int h[N], sum = 0;
int fa[N], top[N], hson[N];
int size[N], dep[N];
int dfn[N], idx[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;
  idx[dfn[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[idx[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, dfn[top[u]], dfn[u]));
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  upmin(res, Query(1, 1, tot, dfn[u], dfn[v]));
  if (u > n) upmin(res, val[fa[u]]);
  return res;
}
}  // namespace TCD
namespace Graph {
struct Edge {
  int to, next;
} e[N << 1];
int h[N], sum = 0;
int pre[N], low[N], dfn = 0;
int bcc[N];
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) {
  pre[u] = low[u] = ++dfn;
  stk.push(u);
  for (int tmp = h[u]; tmp; tmp = e[tmp].next) {
    int v = e[tmp].to;
    if (!pre[v]) {
      Tarjan(v);
      upmin(low[u], low[v]);
      if (low[v] >= pre[u]) {
        int o;
        tot++;
        do {
          o = stk.top();
          stk.pop();
          bcc[o] = tot;
          TCD::add_edge(o, tot);
        } while (o != v);
        TCD::add_edge(u, tot);
      }
    } else
      upmin(low[u], pre[v]);
  }
}
}  // namespace Graph
int main() {
  int u, v;
  tot = n = read();
  m = read();
  q = read();
  for (int i = 1; i <= n; i++) val[i] = read();
  for (int i = 1; i <= m; i++) {
    u = read();
    v = read();
    Graph::add_edge(u, v);
    Graph::add_edge(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!Graph::pre[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 = Get();
    while (opt != 'C' && opt != 'A') opt = Get();
    u = read();
    v = read();
    if (opt == 'C') {
      TCD::Modify(1, 1, tot, TCD::dfn[u], v);
      if (u == 1) {
        val[u] = v;
        continue;
      }
      int o = TCD::fa[u];
      st[o - n].erase(st[o - n].find(val[u]));
      st[o - n].insert(v);
      int minv = *st[o - n].begin();
      if (minv == val[o]) {
        val[u] = v;
        continue;
      }
      TCD::Modify(1, 1, tot, TCD::dfn[o], minv);
      val[o] = minv;
      val[u] = v;
    } else
      print(TCD::PathQuery(u, v));
  }
  flush();
  return 0;
}