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;
const int N = 2e5 + 5;
const int inf = 1e9 + 2;
namespace lct {
struct data {
  int ch[2], rev, val, mi, f;
  data(int x = inf) { ch[0] = ch[1] = 0, val = mi = x; }
} s[N];
int sta[N];
int get(int x) { return s[s[x].f].ch[1] == x; }
int isr(int x) { return s[s[x].f].ch[0] != x && s[s[x].f].ch[1] != x; }
void pushup(int x) {
  s[x].mi = min(s[x].val, min(s[s[x].ch[0]].mi, s[s[x].ch[1]].mi));
}
void mark(int x) {
  if (!x) return;
  swap(s[x].ch[0], s[x].ch[1]), s[x].rev ^= 1;
}
void pushdown(int x) {
  if (s[x].rev) mark(s[x].ch[0]), mark(s[x].ch[1]), s[x].rev = 0;
}
void rotate(int x) {
  int old = s[x].f, fold = s[old].f, which = get(x);
  if (!isr(old)) s[fold].ch[s[fold].ch[1] == old] = x;
  s[old].ch[which] = s[x].ch[which ^ 1];
  if (s[old].ch[which]) s[s[old].ch[which]].f = old;
  s[x].ch[which ^ 1] = old, s[old].f = x, s[x].f = fold;
  pushup(old), pushup(x);
}
void splay(int x) {
  int u = x, v = 0, fa;
  for (sta[++v] = u; !isr(u); u = s[u].f) sta[++v] = s[u].f;
  for (; v; --v) pushdown(sta[v]);
  for (u = s[u].f; (fa = s[x].f) != u; rotate(x))
    if (s[fa].f != u) rotate(get(fa) == get(x) ? fa : x);
}
int Access(int x) {
  int y = 0;
  for (; x; y = x, x = s[x].f) splay(x), s[x].ch[1] = y, pushup(x);
  return y;
}
void makert(int x) { Access(x), splay(x), mark(x); }
void split(int x, int y) { makert(x), Access(y), splay(y); }
void link(int x, int y) { s[x].f = y; }
int get_lca(int x, int y) {
  Access(x);
  return Access(y);
}
};  // namespace lct
vector<int> G[N];
int val[N], dfn[N], low[N], S[N], tim, top, tot;
int hd[N], to[N], nex[N], edges, n, m, Q;
int fa[N];
multiset<int> mi[N];
void add(int u, int v) { nex[++edges] = hd[u], hd[u] = edges, to[edges] = v; }
void tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  S[++top] = u;
  for (int i = hd[u]; i; i = nex[i]) {
    int v = to[i];
    if (!dfn[v]) {
      tarjan(v), low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        ++tot;
        G[tot].push_back(u);
        G[u].push_back(tot);
        for (int x = 0; x != v; --top) {
          x = S[top];
          G[tot].push_back(x);
          G[x].push_back(tot);
        }
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
void dfs(int x, int ff) {
  if (ff) lct::link(x, ff);
  if (x <= n) {
    if (ff) mi[ff].insert(val[x]);
    lct::s[x].val = lct::s[x].mi = val[x];
  }
  for (int i = 0; i < G[x].size(); ++i) {
    int y = G[x][i];
    if (y != ff) fa[y] = x, dfs(y, x);
  }
  if (x > n) {
    lct::s[x].val = lct::s[x].mi = *mi[x].begin();
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= n; ++i) scanf("%d", &val[i]);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  tot = n;
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i);
  dfs(1, 0);
  val[0] = inf;
  for (int i = 1; i <= Q; ++i) {
    char ch[2];
    int x, b;
    scanf("%s%d%d", ch, &x, &b);
    if (ch[0] == 'C') {
      lct::splay(x);
      lct::s[x].val = b;
      lct::pushup(x);
      if (fa[x]) {
        mi[fa[x]].erase(mi[fa[x]].lower_bound(val[x]));
        mi[fa[x]].insert(b);
        lct::splay(fa[x]);
        lct::s[fa[x]].val = *mi[fa[x]].begin();
        lct::pushup(fa[x]);
      }
      val[x] = b;
    } else {
      int lca = lct::get_lca(x, b);
      if (lca <= n) lca = 0;
      lct::split(x, b);
      printf("%d\n", min(lct::s[b].mi, val[fa[lca]]));
      lct::makert(1);
    }
  }
  return 0;
}