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;
long long power(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2, md) % md
                      : power(a * a % md, b / 2, md) % md));
}
const int xn = 2e5 + 10;
const int xm = 18;
const int sq = 320;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
const long double eps = 1e-15;
const int mod = 1e9 + 7;
const int base = 257;
int n, m, q, a[xn], H[xn], dp[xn], ptr, TM, seg[xn << 2];
int par[xm][xn], sz[xn], hd[xn], stm[xn], hvy[xn];
stack<int> sk;
set<pair<int, int> > st[xn];
vector<int> G[xn], adj[xn];
bool mark[xn];
void preDFS(int v, int p = -1) {
  mark[v] = true;
  sk.push(v);
  dp[v] = H[v];
  for (int u : G[v]) {
    if (mark[u]) {
      dp[v] = min(dp[v], H[u]);
      continue;
    }
    H[u] = H[v] + 1;
    preDFS(u, v);
    dp[v] = min(dp[v], dp[u]);
  }
  if (dp[v] < H[v] - 1 || v == 1) return;
  ++ptr;
  while (true) {
    int u = sk.top();
    sk.pop();
    adj[u].push_back(ptr);
    adj[ptr].push_back(u);
    if (u == v) break;
  }
  adj[p].push_back(ptr);
  adj[ptr].push_back(p);
}
void DFS(int v) {
  for (int i = 1; i < xm; ++i) par[i][v] = par[i - 1][par[i - 1][v]];
  sz[v] = 1;
  for (int u : adj[v]) {
    if (u == par[0][v]) continue;
    par[0][u] = v;
    H[u] = H[v] + 1;
    DFS(u);
    sz[v] += sz[u];
    if (sz[hvy[v]] < sz[u]) hvy[v] = u;
  }
}
void HLDFS(int v) {
  stm[v] = TM++;
  hd[v] = v;
  if (hvy[par[0][v]] == v) hd[v] = hd[par[0][v]];
  if (hvy[v]) HLDFS(hvy[v]);
  for (int u : adj[v])
    if (u != par[0][v] && u != hvy[v]) HLDFS(u);
}
void modify(int id, int l, int r, int pos, int val) {
  if (r - l == 1) {
    seg[id] = val;
    return;
  }
  int mid = l + r >> 1;
  if (pos < mid)
    modify(id << 1, l, mid, pos, val);
  else
    modify(id << 1 | 1, mid, r, pos, val);
  seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}
int get(int id, int l, int r, int ql, int qr) {
  if (qr <= l || r <= ql || qr <= ql) return inf;
  if (ql <= l && r <= qr) return seg[id];
  int mid = l + r >> 1;
  return min(get(id << 1, l, mid, ql, qr), get(id << 1 | 1, mid, r, ql, qr));
}
int LCA(int v, int u) {
  if (H[u] < H[v]) swap(v, u);
  for (int i = xm - 1; 0 <= i; --i)
    if ((1 << i) <= H[u] - H[v]) u = par[i][u];
  if (v == u) return v;
  for (int i = xm - 1; 0 <= i; --i)
    if (par[i][v] != par[i][u]) v = par[i][v], u = par[i][u];
  return par[0][v];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) {
    int v, u;
    cin >> v >> u;
    G[v].push_back(u);
    G[u].push_back(v);
  }
  ptr = n;
  preDFS(1);
  H[1] = 0;
  H[0] = -1;
  DFS(1);
  HLDFS(1);
  fill(seg, seg + (xn << 2), inf);
  for (int v = 2; v <= n; ++v) st[par[0][v]].insert({a[v], v});
  for (int i = n + 1; i <= ptr; ++i)
    st[i].insert({inf, -1}), a[i] = (st[i].begin()->first);
  for (int i = 1; i <= ptr; ++i) modify(1, 0, TM, stm[i], a[i]);
  a[0] = inf;
  while (q--) {
    char c;
    int v, u, w;
    cin >> c >> v;
    if (c == 'C') {
      cin >> w;
      modify(1, 0, TM, stm[v], w);
      st[par[0][v]].erase({a[v], v});
      a[v] = w;
      st[par[0][v]].insert({a[v], v});
      a[par[0][v]] = st[par[0][v]].begin()->first;
      modify(1, 0, TM, stm[par[0][v]], a[par[0][v]]);
    } else {
      cin >> u;
      int ans = inf;
      int lca = LCA(v, u);
      while (H[lca] <= H[hd[v]])
        ans = min(ans, get(1, 0, TM, stm[hd[v]], stm[v] + 1)),
        v = par[0][hd[v]];
      ans = min(ans, get(1, 0, TM, stm[lca], stm[v] + 1));
      while (H[lca] <= H[hd[u]])
        ans = min(ans, get(1, 0, TM, stm[hd[u]], stm[u] + 1)),
        u = par[0][hd[u]];
      ans = min(ans, get(1, 0, TM, stm[lca], stm[u] + 1));
      if (n < lca) ans = min(ans, a[par[0][lca]]);
      cout << ans << '\n';
    }
  }
  return 0;
}