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;
const int N = 2e5 + 5;
struct Heap {
  priority_queue<int, vector<int>, greater<int> > P, Q;
  void add(int first) { P.emplace(first); }
  void del(int first) { Q.emplace(first); }
  void adjust() {
    while (!Q.empty() && P.top() == Q.top()) P.pop(), Q.pop();
  }
  int top() {
    adjust();
    return P.top();
  }
} Q[N];
struct SegmentTree {
  int t[N << 1];
  void update(int first, int k) {
    for (t[first += N] = k; first != 1; first >>= 1)
      t[first >> 1] = min(t[first], t[first ^ 1]);
  }
  int query(int l, int r) {
    int ret = 2e9;
    for (l += N, r += N + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) ret = min(ret, t[l++]);
      if (r & 1) ret = min(ret, t[--r]);
    }
    return ret;
  }
} tree;
int n, sz, m, q, w[N];
vector<vector<int> > g(N), bcc;
int low[N], pre[N], art[N], id[N];
bitset<N> idart;
void tarjan(int u, int p) {
  static int idx = 0;
  static stack<int> S;
  pre[u] = low[u] = ++idx;
  S.emplace(u);
  int child = 0;
  for (int v : g[u])
    if (v != p) {
      if (!pre[v]) {
        ++child;
        tarjan(v, u);
        low[u] = min(low[u], low[v]);
        if ((!p && child > 1) || (p && low[v] >= pre[u])) art[u] = true;
        if (low[v] >= pre[u]) {
          bcc.emplace_back(1, u);
          while (bcc.back().back() != v) {
            bcc.back().emplace_back(S.top());
            S.pop();
          }
        }
      } else
        low[u] = min(low[u], pre[v]);
    }
}
int par[N], dep[N], spi[N], rot[N], pos[N];
int dfs(int u, int p) {
  par[u] = p, dep[u] = dep[p] + 1;
  int sz = 1;
  pair<int, int> ret(0, -1);
  for (int v : g[u])
    if (v != p) {
      int z = dfs(v, u);
      sz += z, ret = max(ret, pair<int, int>(z, v));
    }
  spi[u] = ret.second;
  return sz;
}
void gen_bct() {
  tarjan(1, 0);
  g.clear(), g.emplace_back(0);
  for (int i = 1; i <= n; i++)
    if (art[i]) {
      g.emplace_back(0);
      idart[id[i] = g.size() - 1] = true;
      Q[id[i]].add(w[i]);
    }
  for (vector<int> &cc : bcc) {
    g.emplace_back(0);
    for (int u : cc) {
      if (art[u])
        g[g.size() - 1].emplace_back(id[u]),
            g[id[u]].emplace_back(g.size() - 1);
      else
        id[u] = g.size() - 1, Q[g.size() - 1].add(w[u]);
    }
  }
  sz = g.size() - 1;
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    if (art[i]) Q[par[id[i]]].add(w[i]);
  for (int i = 1, idx = 0; i <= sz; i++)
    if (spi[par[i]] != i)
      for (int j = i; j != -1; j = spi[j]) rot[j] = i, pos[j] = ++idx;
  for (int i = 1; i <= sz; i++) tree.update(pos[i], Q[i].top());
}
pair<int, int> hld_query(int a, int b) {
  int ans = 2e9;
  while (rot[a] != rot[b]) {
    if (dep[rot[a]] < dep[rot[b]]) swap(a, b);
    ans = min(ans, tree.query(pos[rot[a]], pos[a]));
    a = par[rot[a]];
  }
  if (dep[a] < dep[b]) swap(a, b);
  ans = min(ans, tree.query(pos[b], pos[a]));
  return pair<int, int>(ans, b);
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", w + i);
  for (int i = 1, a, b; i <= m; i++) {
    scanf("%d %d", &a, &b);
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  gen_bct();
  for (int i = 1; i <= q; i++) {
    char T;
    int a, b;
    scanf(" %c %d %d", &T, &a, &b);
    if (T == 'A') {
      if (a == b)
        printf("%d\n", w[a]);
      else {
        a = id[a], b = id[b];
        if (a == b) {
          int now = tree.query(pos[a], pos[a]);
          if (!idart[a] && par[a]) now = min(now, Q[par[a]].top());
          printf("%d\n", now);
        } else {
          pair<int, int> now = hld_query(a, b);
          if (!idart[now.second] && par[now.second])
            now.first = min(now.first, Q[par[now.second]].top());
          printf("%d\n", now.first);
        }
      }
    } else {
      int pre = w[a];
      w[a] = b, a = id[a];
      Q[a].del(pre), Q[a].add(b);
      tree.update(pos[a], Q[a].top());
      if (idart[a] && par[a]) {
        Q[par[a]].del(pre), Q[par[a]].add(b);
        tree.update(pos[par[a]], Q[par[a]].top());
      }
    }
  }
  return 0;
}