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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 100;
const int INF = 1e9;
vector<pair<int, int>> edges;
vector<int> g[N];
vector<int> tin(N), tout(N), min_tin(N), comp(N), used(N), val, sizes(N),
    root(N), par(N, -1);
vector<vector<int>> components;
vector<int> is_artic(N);
multiset<int> sets[N];
int timer = 0;
int cur_size = 0;
struct SegmentTree {
  vector<int> t, a;
  int n;
  SegmentTree(vector<int> _a) {
    a = _a;
    n = (int)a.size();
    t.assign(4 * n, INF);
    build(0, 0, n);
  }
  void build(int v, int l, int r) {
    if (l + 1 == r) {
      t[v] = a[l];
      return;
    }
    int mid = (l + r) / 2;
    build(v * 2 + 1, l, mid);
    build(v * 2 + 2, mid, r);
    t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
  }
  void upd(int pos, int x) { upd(0, 0, n, pos, x); }
  void upd(int v, int l, int r, int pos, int x) {
    if (l + 1 == r) {
      t[v] = x;
      return;
    }
    int mid = (l + r) / 2;
    if (pos < mid)
      upd(v * 2 + 1, l, mid, pos, x);
    else
      upd(v * 2 + 2, mid, r, pos, x);
    t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
  }
  int qu(int ql, int qr) {
    qr++;
    assert(ql < qr);
    int ret = qu(0, 0, n, ql, qr);
    assert(ret != INF);
    return ret;
  }
  int qu(int v, int l, int r, int ql, int qr) {
    if (qr <= l || r <= ql) return INF;
    if (ql <= l && r <= qr) return t[v];
    int mid = (l + r) / 2;
    return min(qu(v * 2 + 1, l, mid, ql, qr), qu(v * 2 + 2, mid, r, ql, qr));
  }
};
vector<int> st;
void dfs1(int v, int p) {
  used[v] = 1;
  st.push_back(v);
  min_tin[v] = tin[v] = timer++;
  int children = 0;
  for (auto u : g[v]) {
    if (u == p) continue;
    if (!used[u]) {
      children++;
      int prev_size = (int)st.size();
      dfs1(u, v);
      if ((v != 0 && tin[v] <= min_tin[u]) || (v == 0 && children > 1)) {
        is_artic[v] = 1;
        cur_size++;
        components.push_back({v});
        while ((int)st.size() > prev_size) {
          int x = st.back();
          components.back().push_back(x);
          comp[x] = cur_size;
          st.pop_back();
        }
        edges.push_back(make_pair(cur_size, v));
      }
      min_tin[v] = min(min_tin[v], min_tin[u]);
    } else {
      min_tin[v] = min(min_tin[v], tin[u]);
    }
  }
  tout[v] = timer;
}
void dfs2(int v, int p) {
  sizes[v] = 1;
  par[v] = p;
  for (auto &u : g[v]) {
    if (u == p) continue;
    dfs2(u, v);
    sizes[v] += sizes[u];
    if (sizes[u] > sizes[g[v][0]]) swap(u, g[v][0]);
  }
}
void dfs3(int v, int p) {
  tin[v] = timer++;
  for (auto u : g[v]) {
    if (u == p) continue;
    root[u] = (u == g[v][0] ? root[v] : u);
    dfs3(u, v);
  }
  tout[v] = timer;
}
int ancestor(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }
void go(int &a, int &b, int &ans, SegmentTree &t) {
  while (!ancestor(root[a], b)) {
    ans = min(ans, t.qu(tin[root[a]], tin[a]));
    a = root[a];
    a = par[a];
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  cur_size = n;
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  auto add_edge = [&](int v, int u) {
    g[v].push_back(u);
    g[u].push_back(v);
  };
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    add_edge(v, u);
  }
  dfs1(0, -1);
  if ((int)st.size() > 1) {
    components.push_back(st);
    while ((int)st.size()) {
      int v = st.back();
      comp[v] = cur_size;
      st.pop_back();
      cur_size++;
    }
  }
  fill(used.begin(), used.end(), 0);
  timer = 0;
  cur_size = (int)components.size();
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  vector<int> cuts;
  for (int i = 0; i < n; i++) {
    if (is_artic[i]) {
      cuts.push_back(i);
      comp[i] = cur_size++;
    }
  }
  for (int i = 0; i < (int)components.size(); i++) {
    for (auto v : components[i]) {
      if (is_artic[v]) {
        add_edge(comp[v], i);
      } else
        comp[v] = i;
    }
  }
  dfs2(0, -1);
  dfs3(0, -1);
  val.assign(cur_size, INF);
  for (int i = 0; i < n; i++) {
    if (is_artic[i] && par[comp[i]] != -1) {
      int v = par[comp[i]];
      val[v] = min(val[v], w[i]);
      sets[v].insert(w[i]);
    }
    val[comp[i]] = min(val[comp[i]], w[i]);
    sets[comp[i]].insert(w[i]);
  }
  vector<int> tmp(cur_size);
  for (int i = 0; i < cur_size; i++) {
    tmp[tin[i]] = val[i];
  }
  SegmentTree t(tmp);
  while (q--) {
    char op;
    cin >> op;
    if (op == 'A') {
      int v, u;
      cin >> v >> u;
      v--;
      u--;
      if (v == u) {
        cout << w[v] << '\n';
        continue;
      }
      v = comp[v], u = comp[u];
      int ans = INF;
      go(v, u, ans, t);
      go(u, v, ans, t);
      if (!ancestor(v, u)) swap(v, u);
      if (v < (int)components.size() && par[v] != -1) {
        assert(par[v] >= (int)components.size());
        ans = min(ans, w[cuts[par[v] - (int)components.size()]]);
      }
      ans = min(ans, t.qu(tin[v], tin[u]));
      cout << ans << '\n';
    } else {
      int v, x;
      cin >> v >> x;
      v--;
      if (is_artic[v] && par[comp[v]] != -1) {
        int u = par[comp[v]];
        assert(u < (int)components.size());
        assert(sets[u].find(w[v]) != sets[u].end());
        sets[u].erase(sets[u].find(w[v]));
        sets[u].insert(x);
        t.upd(tin[u], *sets[u].begin());
      }
      sets[comp[v]].erase(sets[comp[v]].find(w[v]));
      sets[comp[v]].insert(x);
      w[v] = x;
      t.upd(tin[comp[v]], *sets[comp[v]].begin());
    }
  }
}
