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;
inline int setBit(int N, int pos) { return N = N | (1 << pos); }
inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }
const int inf = 2e9;
namespace BCT {
vector<int> E[200000 + 10], stck, BCC[200000 + 10], myBCC[200000 + 10];
int n, low[200000 + 10], disc[200000 + 10], BCC_cnt, parent[200000 + 10];
bool vis[200000 + 10], pushed[200000 + 10], AP[200000 + 10];
bool isAP(int u, int v, int children) {
  if (parent[u] == -1) {
    if (children > 1) return true;
    return false;
  } else {
    if (low[v] >= disc[u]) return true;
    return false;
  }
}
void dfs(int node) {
  vis[node] = 1;
  stck.push_back(node);
  if (parent[node] == -1)
    disc[node] = low[node] = 1;
  else
    disc[node] = low[node] = disc[parent[node]] + 1;
  int children = 0, u = node;
  for (auto v : E[u]) {
    if (!vis[v]) {
      children++;
      parent[v] = u;
      dfs(v);
      low[u] = min(low[u], low[v]);
      if (isAP(u, v, children)) {
        pushed[u] = 1;
        BCC_cnt++;
        myBCC[u].push_back(BCC_cnt);
        BCC[BCC_cnt].push_back(u);
        while (true) {
          int nw = stck.back();
          myBCC[nw].push_back(BCC_cnt);
          BCC[BCC_cnt].push_back(nw);
          stck.pop_back();
          if (nw == v) break;
        }
      }
    } else if (v != parent[u])
      low[u] = min(low[u], disc[v]);
  }
}
void find_BCC() {
  for (int i = 0; i <= 200000; i++) BCC[i].clear();
  memset((parent), -1, sizeof(parent));
  BCC_cnt = 0;
  memset((vis), 0, sizeof(vis));
  memset((AP), 0, sizeof(AP));
  memset((pushed), 0, sizeof(pushed));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      if (!stck.empty()) BCC_cnt++;
      while (!stck.empty()) {
        myBCC[stck.back()].push_back(BCC_cnt);
        BCC[BCC_cnt].push_back(stck.back());
        stck.pop_back();
      }
    }
  }
}
vector<int> tree[200000 + 10];
void create(int _n, int &nNode) {
  n = _n;
  find_BCC();
  for (int i = 1; i <= n; i++) {
    if (myBCC[i].size() > 1) {
      BCC_cnt++;
      AP[BCC_cnt] = 1;
      for (int j = 0; j < myBCC[i].size(); j++) {
        int u = myBCC[i][j];
        int v = BCC_cnt;
        tree[u].push_back(v);
        tree[v].push_back(u);
      }
      myBCC[i].push_back(BCC_cnt);
      BCC[BCC_cnt].push_back(i);
    }
  }
  nNode = BCC_cnt;
}
}  // namespace BCT
namespace HLD {
int parent[200000 + 10], sparseTable[20 + 2][200000 + 10], level[200000 + 10],
    n, subtreeSize[200000 + 10];
vector<int> E[200000 + 10];
int dfs(int node, int par, int L) {
  level[node] = L;
  parent[node] = par;
  subtreeSize[node] = 1;
  for (auto v : E[node]) {
    if (v != par) subtreeSize[node] += dfs(v, node, L + 1);
  }
  return subtreeSize[node];
}
void initSparseTable(int Root) {
  dfs(Root, 0, 1);
  for (int i = 1; i <= n; i++) sparseTable[0][i] = parent[i];
  for (int p = 1; p <= 20; p++) {
    for (int u = 1; u <= n; u++)
      sparseTable[p][u] = sparseTable[p - 1][sparseTable[p - 1][u]];
  }
}
inline int findLCA(int u, int v) {
  if (level[v] > level[u]) swap(u, v);
  for (int i = 20; i >= 0; i--) {
    if ((1 << i) <= level[u] - level[v]) u = sparseTable[i][u];
  }
  if (u == v) return v;
  for (int i = 20; i >= 0; i--) {
    if (sparseTable[i][u] != sparseTable[i][v])
      u = sparseTable[i][u], v = sparseTable[i][v];
  }
  return parent[v];
}
int chainNo = 0, chainHead[200000 + 10], chainSize[200000 + 10],
    chainId[200000 + 10], idxInBaseArray[200000 + 10], baseArray[200000 + 10],
    cnt = 0;
int A[200000 + 10];
int tree[200000 * 4 + 10];
void init(int node, int st, int ed) {
  if (st == ed) {
    tree[node] = baseArray[st];
    return;
  }
  int lft = 2 * node, rght = lft + 1, mid = (st + ed) / 2;
  init(lft, st, mid);
  init(rght, mid + 1, ed);
  tree[node] = min(tree[lft], tree[rght]);
}
void update(int node, int st, int ed, int i, int val) {
  if (st == ed) {
    tree[node] = val;
    return;
  }
  int lft = 2 * node, rght = lft + 1, mid = (st + ed) / 2;
  if (i <= mid)
    update(lft, st, mid, i, val);
  else
    update(rght, mid + 1, ed, i, val);
  tree[node] = min(tree[lft], tree[rght]);
}
int query(int node, int st, int ed, int i, int j) {
  if (i <= st && ed <= j) return tree[node];
  int lft = 2 * node, rght = lft + 1, mid = (st + ed) / 2;
  int ret = inf;
  if (i <= mid) ret = min(ret, query(lft, st, mid, i, j));
  if (j > mid) ret = min(ret, query(rght, mid + 1, ed, i, j));
  return ret;
}
void HLD(int node, int par) {
  cnt++;
  idxInBaseArray[node] = cnt;
  baseArray[cnt] = A[node];
  if (chainHead[chainNo] == -1) chainHead[chainNo] = node;
  chainId[node] = chainNo;
  chainSize[chainNo]++;
  int specialChild = -1, mx = 0;
  for (auto v : E[node]) {
    if (v != par && subtreeSize[v] > mx) {
      mx = subtreeSize[v];
      specialChild = v;
    }
  }
  if (specialChild != -1) HLD(specialChild, node);
  for (auto v : E[node]) {
    if (v != par && v != specialChild) {
      chainNo++;
      HLD(v, node);
    }
  }
}
void HLDConstruct(int _n, int V[], vector<int> G[]) {
  n = _n;
  for (int i = 1; i <= n; i++) A[i] = V[i], E[i] = G[i];
  initSparseTable(n);
  cnt = 0;
  chainNo = 0;
  memset((chainHead), -1, sizeof(chainHead));
  memset((chainSize), 0, sizeof(chainSize));
  HLD(n, -1);
  init(1, 1, n);
}
inline int solve(int u, int v) {
  int ret = inf;
  while (true) {
    if (chainId[u] == chainId[v]) {
      int L = idxInBaseArray[u];
      int R = idxInBaseArray[v];
      ret = min(ret, query(1, 1, n, L, R));
      return ret;
    }
    int head = chainHead[chainId[v]];
    int L = idxInBaseArray[head];
    int R = idxInBaseArray[v];
    ret = min(ret, query(1, 1, n, L, R));
    v = parent[head];
  }
}
inline int query(int u, int v, int &P) {
  int lca = findLCA(u, v);
  P = lca;
  int ret = inf;
  ret = min(solve(lca, u), solve(lca, v));
  return ret;
}
inline void update(int u, int val) {
  int idx = idxInBaseArray[u];
  update(1, 1, n, idx, val);
  A[u] = val;
}
}  // namespace HLD
int n, newN, A[200000 + 10], V[200000 + 10];
struct info {
  int u, x;
};
bool operator<(info a, info b) { return a.x > b.x; }
priority_queue<info> myValues[200000 + 10];
void pre() {
  A[0] = inf;
  BCT::create(n, newN);
  for (int i = 1; i <= n; i++) {
    int b = BCT::myBCC[i].back();
    myValues[b].push({i, A[i]});
  }
  for (int i = 1; i <= newN; i++) myValues[i].push({0, inf});
  for (int i = 1; i <= newN; i++) V[i] = myValues[i].top().x;
  HLD::HLDConstruct(newN, V, BCT::tree);
  for (int i = 1; i <= n; i++) {
    int b = BCT::myBCC[i].back();
    if (b == newN) continue;
    if (BCT::AP[b]) {
      int p = HLD::parent[b];
      myValues[p].push({i, A[i]});
      HLD::update(p, myValues[p].top().x);
    }
  }
}
inline void up(int b, int u, int New) {
  int last = myValues[b].top().x;
  myValues[b].push({u, New});
  while (true) {
    info tmp = myValues[b].top();
    if (A[tmp.u] != tmp.x)
      myValues[b].pop();
    else
      break;
  }
  int nw = myValues[b].top().x;
  if (last != nw) HLD::update(b, nw);
}
inline void update(int u, int val) {
  int b = BCT::myBCC[u].back();
  A[u] = val;
  up(b, u, val);
  if (BCT::AP[b] && b != newN) {
    int p = HLD::parent[b];
    up(p, u, val);
  }
}
inline int query(int u, int v) {
  if (u == v) return A[v];
  int lca;
  int ret = HLD::query(BCT::myBCC[u].back(), BCT::myBCC[v].back(), lca);
  if (!BCT::AP[lca] && lca != newN)
    ret = min(ret, myValues[HLD::parent[lca]].top().x);
  return ret;
}
inline void sf(int &a) {
  int cc = getc(stdin);
  for (; (cc < '0' || cc > '9') && (cc != '-');) cc = getc(stdin);
  bool neg = false;
  if (cc == '-') {
    neg = true;
    cc = getc(stdin);
  }
  int ret = 0;
  for (; cc >= '0' && cc <= '9';) {
    ret = ret * 10 + cc - '0';
    cc = getc(stdin);
  }
  if (neg) ret = -ret;
  a = ret;
}
int main() {
  int m, q, u, v;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) sf(A[i]);
  for (int i = 1; i <= m; i++) {
    sf(u), sf(v);
    BCT::E[u].push_back(v);
    BCT::E[v].push_back(u);
  }
  pre();
  while (q--) {
    char s[5];
    scanf("%s", s);
    sf(u);
    sf(v);
    if (s[0] == 'C')
      update(u, v);
    else
      printf("%d\n", query(u, v));
  }
  return 0;
}
