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 M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << '(' << p.first << "," << p.second << ')';
}
struct BCT {
  int n;
  vector<vector<int>> g;
  vector<bool> cut;
  vector<int> comp;
  BCT() {}
  BCT(int N) : n(N) {
    g.resize(N + 1);
    cut.resize(N + 1, 0);
    comp.resize(N + 1);
    iota(comp.begin(), comp.end(), 0);
  }
  void add_edge(int x, int y) { g[x].push_back(y), g[y].push_back(x); }
  vector<vector<int>> biconnected_comps() {
    vector<bool> vis(n + 1);
    vector<int> dep(n + 1), low(n + 1);
    vector<int> st;
    vector<vector<int>> cmp;
    function<void(int, int)> dfs = [&](int s, int p) {
      vis[s] = true;
      st.push_back(s);
      int cnt = 0;
      low[s] = dep[s];
      for (auto j : g[s]) {
        if (j == p) continue;
        if (vis[j])
          low[s] = min(low[s], dep[j]);
        else {
          dep[j] = dep[s] + 1;
          dfs(j, s);
          low[s] = min(low[s], low[j]);
          if (low[j] >= dep[s]) {
            ++cnt;
            cmp.push_back({s});
            if (p || cnt >= 2) cut[s] = true;
            while (st.back() != j) {
              cmp.back().push_back(st.back());
              st.pop_back();
            }
            st.pop_back();
            cmp.back().push_back(j);
          }
        }
      }
    };
    dfs(1, 0);
    return cmp;
  }
  int build(vector<vector<int>> &g) {
    int cur = n + 1;
    auto f = biconnected_comps();
    g.resize(n + f.size() + 2);
    for (auto &j : f) {
      for (auto &i : j) {
        if (!cut[i]) comp[i] = cur;
        if (cut[i]) g[cur].push_back(i), g[i].push_back(cur);
      }
      ++cur;
    }
    return --cur;
  }
  bool is_cut(int u) {
    if (u <= n) return cut[u];
    return false;
  }
  int &operator[](int u) {
    if (u > comp.size()) assert(false);
    return comp[u];
  }
} bct;
const int N = 200005;
int sub[N], dep[N], par[N];
void dfs_size(int s, int p, vector<vector<int>> &v) {
  sub[s] = 1;
  for (auto j : v[s]) {
    if (j != p) {
      dep[j] = dep[s] + 1;
      par[j] = s;
      dfs_size(j, s, v);
      sub[s] += sub[j];
    }
  }
}
int head[N], pos[N], in[N], out[N], cur = 1;
void hld(int s, int p, int h, vector<vector<int>> &v) {
  head[s] = h;
  int hv = -1, mx = -1;
  pos[s] = cur++;
  in[s] = pos[s];
  for (auto j : v[s])
    if (j != p)
      if (sub[j] > mx) mx = sub[j], hv = j;
  if (hv != -1) hld(hv, s, h, v);
  for (auto j : v[s])
    if (j != p && j != hv) hld(j, s, j, v);
  out[s] = cur - 1;
}
struct node {
  long long sum;
} fake = {2000000000000000000};
struct SEGTREE {
  long long a[N];
  SEGTREE() {}
  node tree[4 * N];
  inline node combine(node a, node b) {
    node ret;
    ret.sum = min(a.sum, b.sum);
    return ret;
  }
  inline node make_node(long long val) {
    node ret;
    ret.sum = val;
    return ret;
  }
  void buildTree(long long v, long long st, long long en) {
    if (st == en) {
      tree[v] = make_node(a[st]);
      return;
    }
    long long mid = (st + en) >> 1;
    buildTree(v << 1, st, mid);
    buildTree(v << 1 | 1, mid + 1, en);
    tree[v] = combine(tree[v << 1], tree[v << 1 | 1]);
  }
  void update(long long v, long long st, long long en, long long in,
              long long val) {
    long long mid = (st + en) >> 1;
    if (st == en) {
      tree[v] = make_node(val);
      a[st] = val;
      return;
    }
    if (in <= mid)
      update(v << 1, st, mid, in, val);
    else
      update(v << 1 | 1, mid + 1, en, in, val);
    tree[v] = combine(tree[v << 1], tree[v << 1 | 1]);
  }
  node query(long long v, long long st, long long en, long long l,
             long long r) {
    if (en < l || st > r) return fake;
    if (st >= l && en <= r) return tree[v];
    long long mid = (st + en) >> 1;
    return combine(query(v << 1, st, mid, l, r),
                   query(v << 1 | 1, mid + 1, en, l, r));
  }
} seg;
int _runtimeTerror_() {
  int n, m, Q;
  cin >> n >> m >> Q;
  vector<int> w(n + 1);
  vector<multiset<int>> A(2 * n + 1);
  for (int i = 1; i <= n; ++i) cin >> w[i];
  BCT G(n);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    G.add_edge(x, y);
  }
  vector<vector<int>> g;
  int root = G.build(g);
  dfs_size(root, 0, g);
  hld(root, 0, root, g);
  for (int i = 1; i <= n; ++i) {
    if (G.is_cut(i)) A[par[i]].insert(w[i]);
    A[G[i]].insert(w[i]);
  }
  for (int i = 1; i <= root; ++i) seg.a[i] = 2000000000000000000;
  for (int i = 1; i <= root; ++i) {
    if (!A[i].empty()) {
      seg.a[in[i]] = *A[i].begin();
    }
  }
  seg.buildTree(1, 1, root);
  auto updd = [&](int u, int rm, int x) {
    A[u].erase(A[u].find(rm));
    A[u].insert(x);
    seg.update(1, 1, root, in[u], *A[u].begin());
  };
  auto upd = [&](int u, int x) {
    if (!G.is_cut(u)) {
      updd(G[u], w[u], x);
      w[u] = x;
      return;
    }
    updd(u, w[u], x);
    updd(par[u], w[u], x);
    w[u] = x;
  };
  auto query = [&](int a, int b) {
    if (a == b) return 1ll * w[a];
    a = G[a], b = G[b];
    long long ans = 2000000000000000000;
    for (; head[a] != head[b]; b = par[head[b]]) {
      if (dep[head[a]] > dep[head[b]]) swap(a, b);
      amin(ans, seg.query(1, 1, root, pos[head[b]], pos[b]).sum);
    }
    if (dep[a] > dep[b]) swap(a, b);
    amin(ans, seg.query(1, 1, root, pos[a], pos[b]).sum);
    if (!G.is_cut(a))
      amin(ans, seg.query(1, 1, root, pos[par[a]], pos[par[a]]).sum);
    return ans;
  };
  for (int _ = 0; _ < Q; ++_) {
    char c;
    int x, y;
    cin >> c >> x >> y;
    if (c == 'C')
      upd(x, y);
    else
      cout << query(x, y) << "\n";
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) _runtimeTerror_();
  return 0;
}