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 + 10;
int n, m, q;
int val[N];
struct Graph {
  int to[N << 1], nxt[N << 1], head[N], cnt;
  void push(int x, int y) {
    cnt++;
    to[cnt] = y;
    nxt[cnt] = head[x];
    head[x] = cnt;
  }
} Gr[2];
Graph *G1 = &Gr[0], *G2 = &Gr[1];
int dfn[N], low[N], tot, stk[N], top;
void tarjan(int x) {
  stk[++top] = x;
  dfn[x] = low[x] = ++dfn[0];
  for (int i = G1->head[x]; i; i = G1->nxt[i]) {
    int y = G1->to[i];
    if (dfn[y])
      low[x] = min(low[x], dfn[y]);
    else {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] == dfn[x]) {
        tot++;
        while (1) {
          G2->push(tot, stk[top]);
          G2->push(stk[top], tot);
          top--;
          if (stk[top + 1] == y) break;
        }
        G2->push(tot, x);
        G2->push(x, tot);
      }
    }
  }
}
int fa[N], ch[N][2], rev[N], va[N], mn[N];
inline bool get(int x) { return ch[fa[x]][1] == x; }
inline bool nroot(int x) { return ch[fa[x]][0] == x || ch[fa[x]][1] == x; }
void update(int x) {
  mn[x] = va[x];
  if (ch[x][0]) mn[x] = min(mn[x], mn[ch[x][0]]);
  if (ch[x][1]) mn[x] = min(mn[x], mn[ch[x][1]]);
}
void reverse(int x) {
  rev[x] ^= 1;
  swap(ch[x][0], ch[x][1]);
}
void pushdown(int x) {
  if (rev[x]) {
    if (ch[x][0]) reverse(ch[x][0]);
    if (ch[x][1]) reverse(ch[x][1]);
    rev[x] = 0;
  }
}
void rotate(int x) {
  int y = fa[x], z = fa[y], k = get(x), w = ch[x][!k];
  if (nroot(y)) ch[z][get(y)] = x;
  ch[y][k] = w;
  ch[x][!k] = y;
  if (w) fa[w] = y;
  fa[y] = x;
  fa[x] = z;
  update(y);
}
void pushall(int x) {
  if (nroot(x)) pushall(fa[x]);
  pushdown(x);
}
void splay(int x) {
  pushall(x);
  while (nroot(x)) {
    if (nroot(fa[x])) rotate(get(x) ^ get(fa[x]) ? x : fa[x]);
    rotate(x);
  }
  update(x);
}
int access(int x) {
  int y;
  for (y = 0; x; x = fa[y = x]) {
    splay(x);
    ch[x][1] = y;
    update(x);
  }
  return y;
}
void makeroot(int x) {
  access(x);
  splay(x);
  reverse(x);
}
void split(int x, int y) {
  makeroot(x);
  access(y);
  splay(y);
}
void modify(int x, int y) {
  splay(x);
  va[x] = y;
  update(x);
}
int query(int x, int y) {
  split(x, y);
  return mn[y];
}
int lca(int x, int y) {
  makeroot(1);
  access(x);
  return access(y);
}
multiset<int> st[N];
int Fa[N];
void dfs(int x, int fx) {
  Fa[x] = fx;
  for (int i = G2->head[x]; i; i = G2->nxt[i]) {
    int y = G2->to[i];
    if (y == fx) continue;
    fa[y] = x;
    dfs(y, x);
    if (x > n) st[x].insert(val[y]);
  }
  if (x <= n)
    va[x] = val[x];
  else
    va[x] = *st[x].begin();
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    G1->push(x, y);
    G1->push(y, x);
  }
  tot = n;
  tarjan(1);
  dfs(1, 0);
  while (q-- > 0) {
    char op;
    int x, y;
    cin >> op >> x >> y;
    if (op == 'C') {
      if (Fa[x]) {
        int fx = Fa[x];
        st[fx].erase(st[fx].find(val[x]));
        st[fx].insert(y);
        modify(fx, *st[fx].begin());
      }
      val[x] = y;
      modify(x, y);
    } else {
      int res = query(x, y);
      int nd = lca(x, y);
      if (nd > n) {
        if (Fa[nd]) res = min(res, val[Fa[nd]]);
      }
      cout << res << endl;
    }
  }
  return 0;
}