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>
#pragma GCC optimize("Ofast")
using namespace std;
const int INF = 1e9 + 7, N = 2e5 + 7;
vector<int> G[N], bcc_id[N], s;
multiset<int> all_w[N];
int cnt, low[N], vis[N], t, id[N], w[N], ww[N];
void dfs(int u, int p = 0) {
  low[u] = vis[u] = ++t;
  s.push_back(u);
  for (int v : G[u])
    if (v != p) {
      if (vis[v])
        low[u] = min(low[u], vis[v]);
      else {
        dfs(v, u);
        if (low[v] >= vis[u]) {
          ++cnt;
          int k;
          do {
            k = s.back();
            s.pop_back();
            bcc_id[k].push_back(cnt);
          } while (k != v);
          bcc_id[u].push_back(cnt);
        }
        low[u] = min(low[v], low[u]);
      }
    }
}
vector<int> g[N], b;
int sz[N], up[N], tin[N], pa[N], depth[N];
bool iscut[N];
void dfs_sz(int u, int p = 0, int cur_depth = 1) {
  sz[u] = 1, pa[u] = p, depth[u] = cur_depth;
  for (int i = 0; i < (int)g[u].size() - 1; i++) {
    if (g[u][i] == p) swap(g[u][i], g[u].back());
    dfs_sz(g[u][i], u, cur_depth + 1);
    sz[u] += sz[g[u][i]];
    if (sz[g[u][i]] > sz[g[u][0]]) swap(g[u][i], g[u][0]);
  }
}
void dfs_hld(int u) {
  tin[u] = b.size();
  b.push_back(u);
  for (int i = 0; i < (int)g[u].size() - 1; i++) {
    if (i == 0)
      up[g[u][i]] = up[u];
    else
      up[g[u][i]] = g[u][i];
    dfs_hld(g[u][i]);
  }
}
int seg[4 * N];
void build(int v = 1, int tl = 0, int tr = b.size()) {
  if (tr - tl == 1) {
    seg[v] = ww[b[tl]];
    return;
  }
  int tm = (tl + tr) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm, tr);
  seg[v] = min(seg[v * 2], seg[v * 2 + 1]);
}
void upd(int pos, int val, int v = 1, int tl = 0, int tr = b.size()) {
  if (tr - tl == 1) {
    seg[v] = val;
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos < tm)
    upd(pos, val, v * 2, tl, tm);
  else
    upd(pos, val, v * 2 + 1, tm, tr);
  seg[v] = min(seg[v * 2], seg[v * 2 + 1]);
}
int qry(int l, int r, int v = 1, int tl = 0, int tr = b.size()) {
  if (l >= r) return INF;
  if (l == tl && r == tr) return seg[v];
  int tm = (tl + tr) / 2;
  return min(qry(l, min(r, tm), v * 2, tl, tm),
             qry(max(tm, l), r, v * 2 + 1, tm, tr));
}
int query(int u, int v) {
  int ans = min(ww[u], ww[v]);
  while (true) {
    if (up[u] == up[v]) {
      if (depth[u] > depth[v]) swap(u, v);
      ans = min(ans, qry(tin[u], tin[v] + 1));
      break;
    }
    if (depth[up[u]] > depth[up[v]]) swap(u, v);
    ans = min(ans, qry(tin[up[v]], tin[v] + 1));
    v = pa[up[v]];
  }
  return ans;
}
int lca(int u, int v) {
  if (up[u] == up[v]) return depth[u] < depth[v] ? u : v;
  if (depth[up[u]] > depth[up[v]]) swap(u, v);
  return lca(u, pa[up[v]]);
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1);
  memset(ww, 0x3f, sizeof ww);
  for (int i = 1; i <= n; i++) {
    if (bcc_id[i].size() > 1) {
      id[i] = ++cnt;
      iscut[id[i]] = true;
      ww[id[i]] = w[i];
      all_w[id[i]].insert(w[i]);
      for (int j : bcc_id[i]) {
        g[id[i]].push_back(j);
        g[j].push_back(id[i]);
      }
    } else {
      id[i] = bcc_id[i][0];
      ww[id[i]] = min(ww[id[i]], w[i]);
      all_w[id[i]].insert(w[i]);
    }
  }
  g[1].push_back(0);
  dfs_sz(1);
  up[1] = 1;
  dfs_hld(1);
  for (int i = 1; i <= n; i++) {
    if (bcc_id[i].size() > 1) {
      if (pa[id[i]]) {
        int j = pa[id[i]];
        all_w[j].insert(w[i]);
        ww[j] = *all_w[j].begin();
      }
    }
  }
  build();
  while (q--) {
    char op;
    cin >> op;
    if (op == 'C') {
      int u, val;
      cin >> u >> val;
      int j = id[u];
      all_w[j].erase(w[u]);
      all_w[j].insert(val);
      ww[j] = *all_w[j].begin();
      upd(tin[j], ww[j]);
      if (bcc_id[u].size() > 1) {
        int j = pa[id[u]];
        if (j) {
          all_w[j].erase(w[u]);
          all_w[j].insert(val);
          ww[j] = *all_w[j].begin();
          upd(tin[j], ww[j]);
        }
      }
      w[u] = val;
    } else {
      int u, v;
      cin >> u >> v;
      if (u == v) {
        cout << w[u] << endl;
        continue;
      }
      u = id[u], v = id[v];
      int ans = query(u, v);
      int l = lca(u, v);
      if (pa[l] && iscut[pa[l]]) ans = min(ans, ww[pa[l]]);
      cout << ans << endl;
    }
  }
}