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;
void chkmi(int &x, int y) {
  if (x > y) x = y;
}
void chkmx(int &x, int y) {
  if (x < y) x = y;
}
int Head[100005], E[100005 << 1], Nxt[100005 << 1], tol;
void Edge(int x, int y) {
  E[tol] = y;
  Nxt[tol] = Head[x];
  Head[x] = tol++;
}
struct Heap {
  priority_queue<int, vector<int>, greater<int> > Q;
  priority_queue<int, vector<int>, greater<int> > P;
  void pop(int x) { P.push(x); }
  void push(int x) { Q.push(x); }
  int top() {
    while (!P.empty() && Q.top() == P.top()) Q.pop(), P.pop();
    return Q.top();
  }
} Heap[100005 << 1];
int n, m, q;
vector<int> G[100005 << 1];
vector<int> col[100005];
int dfn[100005], low[100005], Stk[100005];
int dfn_cnt, Stk_top, bcc_id;
void Tarjan(int x) {
  dfn[x] = low[x] = ++dfn_cnt;
  Stk[++Stk_top] = x;
  for (int i = Head[x]; ~i; i = Nxt[i]) {
    int y = E[i];
    if (!dfn[y]) {
      Tarjan(y);
      chkmi(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        bcc_id++;
        while (Stk_top) {
          int k = Stk[Stk_top--];
          G[bcc_id].push_back(k);
          G[k].push_back(bcc_id);
          if (k == y) break;
        }
        G[bcc_id].push_back(x);
        G[x].push_back(bcc_id);
      }
    } else
      chkmi(low[x], dfn[y]);
  }
}
int dep[100005 << 1], Fa[100005 << 1], Top[100005 << 1], sz[100005 << 1],
    son[100005 << 1];
int SgId[100005 << 1], SgId_cnt;
void dfs(int x, int fr) {
  dep[x] = dep[fr] + 1;
  Fa[x] = fr;
  sz[x] = 1;
  son[x] = 0;
  for (int i = (0), _t = (G[x].size() - 1); i <= _t; ++i) {
    int y = G[x][i];
    if (y == fr) continue;
    dfs(y, x);
    sz[x] += sz[y];
    if (sz[y] > sz[son[x]]) son[x] = y;
  }
}
void DFS(int x, int tp) {
  Top[x] = tp;
  SgId[x] = ++SgId_cnt;
  if (son[x]) DFS(son[x], tp);
  for (int i = (0), _t = (G[x].size() - 1); i <= _t; ++i) {
    int y = G[x][i];
    if (y == Fa[x] || y == son[x]) continue;
    DFS(y, y);
  }
}
int val[100005];
int mn[100005 << 3], num[100005 << 1];
void build(int L, int R, int p) {
  if (L == R) {
    mn[p] = num[L];
    return;
  }
  int mid = L + R >> 1;
  build(L, mid, p << 1);
  build(mid + 1, R, p << 1 | 1);
  mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
}
void Update(int L, int R, int p, int x, int v) {
  if (L == R) {
    mn[p] = v;
    return;
  }
  int mid = L + R >> 1;
  if (x <= mid)
    Update(L, mid, p << 1, x, v);
  else
    Update(mid + 1, R, p << 1 | 1, x, v);
  mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
}
int Query(int L, int R, int p, int l, int r) {
  if (L == l && R == r) return mn[p];
  int mid = L + R >> 1;
  if (r <= mid)
    return Query(L, mid, p << 1, l, r);
  else if (l > mid)
    return Query(mid + 1, R, p << 1 | 1, l, r);
  else
    return min(Query(L, mid, p << 1, l, mid),
               Query(mid + 1, R, p << 1 | 1, mid + 1, r));
}
int LCA_Query(int x, int y) {
  int res = 0x3f3f3f3f;
  while (Top[x] != Top[y]) {
    if (dep[Top[x]] < dep[Top[y]]) swap(x, y);
    chkmi(res, Query(1, bcc_id, 1, SgId[Top[x]], SgId[x]));
    x = Fa[Top[x]];
  }
  if (dep[x] < dep[y]) swap(x, y);
  chkmi(res, Query(1, bcc_id, 1, SgId[y], SgId[x]));
  if (y > n) chkmi(res, val[Fa[y]]);
  return res;
}
char op[5];
int main() {
  memset(Head, -1, sizeof(Head));
  scanf("%d%d%d", &n, &m, &q);
  for (int i = (1), _t = (n); i <= _t; ++i) scanf("%d", &val[i]);
  for (int i = (1), _t = (m); i <= _t; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Edge(x, y);
    Edge(y, x);
  }
  bcc_id = n;
  Tarjan(1);
  dfs(1, 0);
  DFS(1, 1);
  for (int i = (1), _t = (n); i <= _t; ++i)
    for (int j = (0), _t = (G[i].size() - 1); j <= _t; ++j)
      if (Fa[i] == G[i][j]) Heap[G[i][j]].push(val[i]);
  for (int i = (1), _t = (n); i <= _t; ++i) num[SgId[i]] = val[i];
  for (int i = (n + 1), _t = (bcc_id); i <= _t; ++i)
    num[SgId[i]] = Heap[i].top();
  build(1, bcc_id, 1);
  for (int i = (1), _t = (q); i <= _t; ++i) {
    int x, y;
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'C') {
      if (Fa[x]) Heap[Fa[x]].pop(val[x]);
      val[x] = y;
      if (Fa[x]) {
        Heap[Fa[x]].push(val[x]);
        Update(1, bcc_id, 1, SgId[Fa[x]], Heap[Fa[x]].top());
      }
      Update(1, bcc_id, 1, SgId[x], val[x]);
    } else
      printf("%d\n", LCA_Query(x, y));
  }
  return 0;
}