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;
const int INF = 2e9;
vector<int> adj[N];
vector<int> Tree[N];
set<int> BCC[N];
set<int> belong[N];
vector<ii> edges_stack;
int parent[N];
int low[N], dfn[N];
int timer = 0, bcc_count = 0;
bool cut[N];
bool is_node[N];
int w[N];
multiset<int> BCC_values[N];
int segTreePos[N];
int dep[N];
int heavy[N];
int root[N];
int st[N << 2];
int n, m, q;
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);
  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] = ++timer;
  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;
        Tree[node].push_back(i);
        Tree[i].push_back(node);
      }
    }
  }
}
int dfs_Tree(int u, int p) {
  parent[u] = p;
  if (p != -1) dep[u] = 1 + dep[p];
  int sz = 1;
  int mx = 0;
  for (int v : Tree[u]) {
    if (v != p) {
      int curr = dfs_Tree(v, u);
      if (curr > mx) {
        mx = curr;
        heavy[u] = v;
      }
      sz += curr;
    }
  }
  return sz;
}
void spread_values() {
  for (int i = 1; i <= bcc_count; i++) {
    for (int u : BCC[i]) {
      if (u == parent[code(i)]) continue;
      BCC_values[i].insert(w[u]);
    }
    w[code(i)] = *(BCC_values[i].begin());
  }
}
void build_chains() {
  int pos = 0;
  for (int chain_root = 1; chain_root <= 3 * n; chain_root++) {
    if (!is_node[chain_root]) continue;
    if (parent[chain_root] == -1 || (heavy[parent[chain_root]] != chain_root)) {
      for (int node = chain_root; node != -1; node = heavy[node]) {
        root[node] = chain_root;
        segTreePos[node] = ++pos;
      }
    }
  }
}
void update(int p, int l, int r, int dx, int val) {
  if (l == r) {
    st[p] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (dx <= mid)
    update(p << 1, l, mid, dx, val);
  else
    update(p << 1 | 1, mid + 1, r, dx, val);
  st[p] = min(st[p << 1], st[p << 1 | 1]);
}
int rmq(int p, int l, int r, int S, int E) {
  if (l >= S && r <= E) return st[p];
  if (l > E || r < S) return INF;
  int mid = (l + r) >> 1;
  int x = rmq(p << 1, l, mid, S, E);
  int y = rmq(p << 1 | 1, mid + 1, r, S, E);
  return min(x, y);
}
void update_values_to_segTree() {
  for (int i = 1; i <= 3 * n; i++) {
    if (!is_node[i]) continue;
    update(1, 1, N - 4, segTreePos[i], w[i]);
  }
}
int query(int u, int v) {
  int ans = INF;
  while (root[u] != root[v]) {
    if (dep[root[u]] < dep[root[v]]) swap(u, v);
    ans = min(ans, rmq(1, 1, N - 4, segTreePos[root[u]], segTreePos[u]));
    u = parent[root[u]];
  }
  if (dep[u] < dep[v]) swap(u, v);
  ans = min(ans, rmq(1, 1, N - 4, segTreePos[v], segTreePos[u]));
  if ((v > n) && (parent[v] != -1)) {
    ans = min(ans, w[parent[v]]);
  }
  return ans;
}
int calc(int u, int v) {
  if (u == v) {
    return w[u];
  }
  if (!cut[u]) u = code(*(belong[u].begin()));
  if (!cut[v]) v = code(*(belong[v].begin()));
  if (u == v) return w[u];
  return query(u, v);
}
void change(int u, int val) {
  if (cut[u]) {
    int comp = decode(parent[u]);
    BCC_values[comp].erase(BCC_values[comp].find(w[u]));
    BCC_values[comp].insert(val);
    w[u] = val;
    int dx = segTreePos[parent[u]];
    w[parent[u]] = *(BCC_values[comp].begin());
    update(1, 1, N - 4, dx, *(BCC_values[comp].begin()));
    update(1, 1, N - 4, segTreePos[u], val);
  } else {
    int comp = *(belong[u].begin());
    BCC_values[comp].erase(BCC_values[comp].find(w[u]));
    BCC_values[comp].insert(val);
    w[u] = val;
    w[code(comp)] = *(BCC_values[comp].begin());
    int dx = segTreePos[code(comp)];
    update(1, 1, N - 4, dx, *(BCC_values[comp].begin()));
  }
}
void init() {
  for (int i = 0; i < (N << 2); i++) {
    st[i] = INF;
  }
  memset(heavy, -1, sizeof heavy);
  memset(parent, -1, sizeof parent);
}
int main() {
  init();
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w[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);
  }
  tarjan_BCC(1, -1);
  make_bcc(-1, -1);
  build_BCC_Tree();
  dfs_Tree(code(1), -1);
  build_chains();
  spread_values();
  update_values_to_segTree();
  while (q--) {
    char type[2];
    int u, v;
    scanf("%s %d %d", type, &u, &v);
    if (type[0] == 'A') {
      printf("%d\n", calc(u, v));
    } else {
      change(u, v);
    }
  }
  return 0;
}
