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;
namespace IO {
const int MAXSIZE = 1 << 18 | 1;
char buf[MAXSIZE], *p1, *p2;
inline int Gc() {
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class T>
void read(T& x) {
  x = 0;
  int f = 0, ch = Gc();
  while (!isdigit(ch)) {
    f |= ch == '-';
    ch = Gc();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = Gc();
  }
  if (f) x = -x;
}
}  // namespace IO
using IO::Gc;
using IO::read;
const int INF = 0x3f3f3f3f;
const int MAXN = (int)1e5 + 5;
int n, m, q, SqIdx;
int weight[MAXN << 1];
multiset<int> M[MAXN << 1];
struct Edge {
  int from, to;
  Edge(int u, int v) : from(u), to(v) {}
};
struct Graph {
  vector<Edge> edges;
  vector<int> G[MAXN << 1];
  inline void AddEdge(int from, int to) {
    edges.push_back(Edge(from, to));
    int eidx = edges.size() - 1;
    G[from].push_back(eidx);
  }
} G, T;
namespace BCC {
int dfn[MAXN], low[MAXN], dfs_clock;
stack<int> S;
void tarjan(int u) {
  dfn[u] = low[u] = ++dfs_clock;
  S.push(u);
  for (size_t i = 0; i < G.G[u].size(); ++i) {
    int v = G.edges[G.G[u][i]].to;
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        ++SqIdx;
        while (true) {
          int x = S.top();
          S.pop();
          T.AddEdge(SqIdx, x);
          T.AddEdge(x, SqIdx);
          if (x == v) break;
        }
        T.AddEdge(SqIdx, u);
        T.AddEdge(u, SqIdx);
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
}  // namespace BCC
namespace HLD {
int son[MAXN << 1], size[MAXN << 1], pre[MAXN << 1], depth[MAXN << 1];
int dfn[MAXN << 1], rnk[MAXN << 1], topfa[MAXN << 1], dfs_clock;
inline void init() {
  dfs_clock = 0;
  memset(son, -1, sizeof son);
}
void dfs1(int u, int fa) {
  size[u] = 1;
  pre[u] = fa;
  depth[u] = depth[fa] + 1;
  for (size_t i = 0; i < T.G[u].size(); ++i) {
    int v = T.edges[T.G[u][i]].to;
    if (v == fa) continue;
    dfs1(v, u);
    size[u] += size[v];
    if (son[u] == -1 || size[son[u]] < size[v]) son[u] = v;
  }
}
void dfs2(int u, int top) {
  dfn[u] = ++dfs_clock;
  rnk[dfs_clock] = u;
  topfa[u] = top;
  if (son[u] == -1) return;
  dfs2(son[u], top);
  for (size_t i = 0; i < T.G[u].size(); ++i) {
    int v = T.edges[T.G[u][i]].to;
    if (v == son[u] || v == pre[u]) continue;
    dfs2(v, v);
  }
}
inline void solve() {
  init();
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i)
    if (pre[i]) M[pre[i]].insert(weight[i]);
  for (int i = n + 1; i <= SqIdx; ++i) weight[i] = *M[i].begin();
}
}  // namespace HLD
namespace SEG {
int datMin[MAXN << 3];
inline void maintain(int nd) {
  datMin[nd] = min(datMin[(nd << 1)], datMin[(nd << 1 | 1)]);
}
void build(int nd, int L, int R) {
  if (L == R) {
    datMin[nd] = weight[HLD::rnk[L]];
    return;
  }
  build((nd << 1), L, (L + ((R - L) >> 1)));
  build((nd << 1 | 1), (L + ((R - L) >> 1)) + 1, R);
  maintain(nd);
}
void modify(int nd, int L, int R, int pos, int val) {
  if (L == R) {
    datMin[nd] = val;
    return;
  }
  if (pos <= (L + ((R - L) >> 1)))
    modify((nd << 1), L, (L + ((R - L) >> 1)), pos, val);
  else
    modify((nd << 1 | 1), (L + ((R - L) >> 1)) + 1, R, pos, val);
  maintain(nd);
}
int query(int nd, int L, int R, int opL, int opR) {
  if (opL <= L && R <= opR) return datMin[nd];
  int ret = INF;
  if (opL <= (L + ((R - L) >> 1)))
    ret = min(query((nd << 1), L, (L + ((R - L) >> 1)), opL, opR), ret);
  if (opR > (L + ((R - L) >> 1)))
    ret = min(query((nd << 1 | 1), (L + ((R - L) >> 1)) + 1, R, opL, opR), ret);
  return ret;
}
}  // namespace SEG
namespace HLD {
int query(int x, int y) {
  int ret = INF;
  while (topfa[x] != topfa[y]) {
    if (depth[topfa[x]] < depth[topfa[y]]) swap(x, y);
    ret = min(ret, SEG::query(1, 1, SqIdx, dfn[topfa[x]], dfn[x]));
    x = pre[topfa[x]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  ret = min(ret, SEG::query(1, 1, SqIdx, dfn[x], dfn[y]));
  if (x > n) ret = min(ret, weight[pre[x]]);
  return ret;
}
}  // namespace HLD
int main() {
  read(n);
  read(m);
  read(q);
  SqIdx = n;
  for (int i = 1; i <= n; ++i) read(weight[i]);
  for (int u, v, i = 1; i <= m; ++i) {
    read(u);
    read(v);
    G.AddEdge(u, v);
    G.AddEdge(v, u);
  }
  BCC::tarjan(1);
  HLD::solve();
  SEG::build(1, 1, SqIdx);
  while (q--) {
    int a, b, w, opt = Gc();
    while (isspace(opt)) opt = Gc();
    switch (opt) {
      case 'A':
        read(a);
        read(b);
        printf("%d\n", HLD::query(a, b));
        break;
      case 'C':
        read(a);
        read(w);
        SEG::modify(1, 1, SqIdx, HLD::dfn[a], w);
        if (HLD::pre[a]) {
          int u = HLD::pre[a];
          M[u].erase(M[u].lower_bound(weight[a]));
          M[u].insert(w);
          if (weight[u] != *M[u].begin()) {
            weight[u] = *M[u].begin();
            SEG::modify(1, 1, SqIdx, HLD::dfn[u], weight[u]);
          }
        }
        weight[a] = w;
        break;
      default:
        puts("ERROR");
    }
  }
  return 0;
}