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>
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int N = 5e5 + 5, L = 20;
const int inf = 2e9;
int p[N][L], dep[N], seg[N << 2];
int sz[N], timer = 1;
struct tt {
  int v, c;
  tt(int x) { v = x, c = 0; }
};
vector<tt> adj[N];
vector<int> ADJ[N];
vector<int> Tree[N];
set<int> BCC[N];
set<int> belong[N];
multiset<int> BCC_ANS[N];
vector<ii> edges_stack;
int low[N], dfn[N];
int timerr = 0, bcc_count = 0;
bool cut[N];
bool is_node[N];
int n, m, q, a[N];
int code(int x) { return x + n + 1; }
int decode(int x) { return x - n - 1; }
void make_bcc(int u, int v) {
  ii E = make_pair(u, v);
  if ((int)edges_stack.size() > 0) bcc_count++;
  while (!edges_stack.empty()) {
    ii E2 = edges_stack.back();
    edges_stack.pop_back();
    int x = E2.first;
    int y = E2.second;
    BCC[bcc_count].insert(x);
    BCC[bcc_count].insert(y);
    belong[x].insert(bcc_count);
    belong[y].insert(bcc_count);
    if (E2 == E) break;
  }
}
void tarjan_BCC(int u, int p) {
  low[u] = dfn[u] = ++timerr;
  int children = 0;
  for (int v : ADJ[u]) {
    if (v == p) continue;
    if (dfn[v] == 0) {
      children++;
      edges_stack.push_back({u, v});
      tarjan_BCC(v, u);
      low[u] = min(low[u], low[v]);
      if (((p == -1) && (children > 1)) || ((p != -1) && (dfn[u] <= low[v]))) {
        cut[u] = 1;
        make_bcc(u, v);
      }
    } else if (v != p) {
      if (dfn[v] < low[u]) {
        low[u] = dfn[v];
        edges_stack.push_back({u, v});
      }
    }
  }
}
void build_BCC_Tree() {
  for (int i = 1; i <= n; i++) {
    if (cut[i]) {
      is_node[i] = true;
      for (int b : belong[i]) {
        int node = code(b);
        is_node[node] = true;
        adj[node].push_back(tt(i));
        adj[i].push_back(tt(node));
      }
    }
  }
}
int baseArray[N], mn[N];
int chainNo, chainInd[N], chainHead[N], posInBase[N];
void dfs(int u, int par = 0) {
  p[u][0] = par;
  dep[u] = 1 + dep[par];
  sz[u] = 1;
  for (auto v : adj[u])
    if (v.v != par) {
      dfs(v.v, u);
      sz[u] += sz[v.v];
    }
}
int jump(int u, int k) {
  for (int i = 0; i < L; i++)
    if (k & (1 << i)) u = p[u][i];
  return u;
}
int LCA(int u, int v) {
  if (u == v) return u;
  if (dep[u] < dep[v]) swap(u, v);
  int dif = dep[u] - dep[v];
  u = jump(u, dif);
  if (u == v) return u;
  for (int i = L - 1; i >= 0; i--)
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  return p[u][0];
}
void HLD(int u, int c = 0, int par = 0) {
  if (chainHead[chainNo] == -1) {
    chainHead[chainNo] = u;
  }
  chainInd[u] = chainNo;
  posInBase[u] = timer;
  baseArray[timer++] = c;
  int sc = -1, ncost;
  for (auto v : adj[u])
    if (v.v != par) {
      if (sc == -1 || sz[sc] < sz[v.v]) {
        sc = v.v;
        ncost = v.c;
      }
    }
  if (sc != -1) {
    HLD(sc, ncost, u);
  }
  for (auto v : adj[u])
    if (v.v != par) {
      if (sc != v.v) {
        chainNo++;
        HLD(v.v, v.c, u);
      }
    }
}
void build(int nd, int L, int R) {
  if (L == R) {
    seg[nd] = inf;
    return;
  }
  int mid = (L + R) >> 1;
  build(nd << 1, L, mid);
  build(nd << 1 | 1, mid + 1, R);
  seg[nd] = min(seg[nd << 1], seg[nd << 1 | 1]);
}
void update(int nd, int L, int R, int idx, int val) {
  if (L == R) {
    seg[nd] = val;
    return;
  }
  int mid = (L + R) >> 1;
  if (idx <= mid)
    update(nd << 1, L, mid, idx, val);
  else
    update(nd << 1 | 1, mid + 1, R, idx, val);
  seg[nd] = min(seg[nd << 1], seg[nd << 1 | 1]);
}
int query(int nd, int L, int R, int from, int to) {
  if (from <= L && R <= to) return seg[nd];
  if (from > R || to < L) return inf;
  int mid = (L + R) >> 1;
  int leftAns = query(nd << 1, L, mid, from, to);
  int rightAns = query(nd << 1 | 1, mid + 1, R, from, to);
  return min(leftAns, rightAns);
}
int query_up(int u, int v) {
  int uchain, vchain = chainInd[v], ANS = inf;
  while (1) {
    uchain = chainInd[u];
    if (uchain == vchain) {
      ANS = min(ANS, query(1, 1, timer, posInBase[v], posInBase[u]));
      break;
    }
    ANS = min(ANS,
              query(1, 1, timer, posInBase[chainHead[uchain]], posInBase[u]));
    u = chainHead[uchain];
    u = p[u][0];
  }
  return ANS;
}
void query(int u, int v) {
  int lca = LCA(u, v);
  int ANS = query_up(u, lca);
  int temp = query_up(v, lca);
  if (temp < ANS) ANS = temp;
  if (!cut[lca] && p[lca][0]) {
    ANS = min(ANS,
              query(1, 1, timer, posInBase[p[lca][0]], posInBase[p[lca][0]]));
  }
  printf("%d\n", ANS);
}
void change(int i, int val) { update(1, 1, timer, posInBase[i], val); }
void solve(int cs) {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    ADJ[u].push_back(v);
    ADJ[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) {
      tarjan_BCC(i, -1);
      make_bcc(-1, -1);
    }
  }
  build_BCC_Tree();
  dfs(code(1));
  HLD(code(1));
  build(1, 1, timer);
  timer--;
  for (int j = 1; j < L; j++)
    for (int i = 1; i <= n + n + n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  for (int i = 1; i <= bcc_count; i++) {
    int u = code(i);
    for (auto v : BCC[i]) {
      if (v == p[u][0]) continue;
      BCC_ANS[i].insert(a[v]);
    }
    a[u] = *BCC_ANS[i].begin();
    update(1, 1, timer, posInBase[u], a[u]);
  }
  for (int i = 1; i <= n; i++) {
    if (cut[i]) {
      update(1, 1, timer, posInBase[i], a[i]);
    }
  }
  char al[2];
  while (q--) {
    scanf("%s", al);
    if (al[0] == 'A') {
      int u, v;
      scanf("%d %d", &u, &v);
      if (u == v) {
        printf("%d\n", a[u]);
        continue;
      }
      if (!cut[u]) u = code(*belong[u].begin());
      if (!cut[v]) v = code(*belong[v].begin());
      if (u == v) {
        printf("%d\n", a[u]);
        continue;
      }
      query(u, v);
    } else {
      int v, w;
      scanf("%d %d", &v, &w);
      if (!cut[v]) {
        int comp = *belong[v].begin();
        BCC_ANS[comp].erase(BCC_ANS[comp].find(a[v]));
        a[v] = w;
        BCC_ANS[comp].insert(a[v]);
        a[code(comp)] = *BCC_ANS[comp].begin();
        change(code(comp), a[code(comp)]);
      } else {
        int comp = decode(p[v][0]);
        BCC_ANS[comp].erase(BCC_ANS[comp].find(a[v]));
        a[v] = w;
        BCC_ANS[comp].insert(a[v]);
        a[code(comp)] = *BCC_ANS[comp].begin();
        change(code(comp), a[code(comp)]);
        change(v, a[v]);
      }
    }
  }
}
void init() {
  timerr = 0, bcc_count = 0;
  memset(chainHead, -1, sizeof chainHead);
  for (int i = 1; i <= 3 * n; i++) {
    adj[i].clear();
    cut[i] = 0;
    Tree[i].clear();
    belong[i].clear();
    BCC[i].clear();
    low[i] = dfn[i] = 0;
    is_node[i] = 0;
  }
}
int main() {
  int t = 1;
  for (int cs = 1; t--; cs++) {
    init();
    solve(cs);
  }
  return 0;
}
