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 = 2e5 + 5;
int min(int x, int y) { return x < y ? x : y; }
void swap(int &x, int &y) { x ^= y ^= x ^= y; }
int n, m, q, w[M];
int read() {
  int x = 0, y = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
int tot = 0, first[M];
struct Edge {
  int nxt, to;
} e[M << 1];
void add(int x, int y) {
  e[++tot] = (Edge){first[x], y};
  first[x] = tot;
}
int cnt;
vector<int> G[M];
multiset<int> nw[M];
namespace YuanFangShu {
int num = 0, top = 0, dfn[M], low[M], sta[M];
void Add(int x, int y) { G[x].push_back(y), G[y].push_back(x); }
void tarjan(int u) {
  dfn[u] = low[u] = ++num;
  sta[++top] = u;
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (!dfn[v]) {
      tarjan(v), low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        cnt++;
        for (int x; x != v; top--) Add(x = sta[top], cnt);
        Add(u, cnt);
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
}  // namespace YuanFangShu
namespace Segment {
int minn[M << 2];
void pushup(int u) { minn[u] = min(minn[u << 1], minn[u << 1 | 1]); }
void Build(int u, int l, int r) {
  minn[u] = 1e9;
  if (l == r) return;
  int mid = (l + r) >> 1;
  Build(u << 1, l, mid), Build(u << 1 | 1, mid + 1, r);
}
void Change(int u, int l, int r, int x, int d) {
  if (l == r) return (void)(minn[u] = d);
  int mid = (l + r) >> 1;
  if (x <= mid)
    Change(u << 1, l, mid, x, d);
  else
    Change(u << 1 | 1, mid + 1, r, x, d);
  pushup(u);
}
int Query(int u, int l, int r, int L, int R) {
  if (l > R || r < L || L > R) return 1e9;
  if (L <= l && r <= R) return minn[u];
  int mid = (l + r) >> 1;
  return min(Query(u << 1, l, mid, L, R), Query(u << 1 | 1, mid + 1, r, L, R));
}
}  // namespace Segment
namespace ShuPou {
using namespace Segment;
int num = 0, de[M], sz[M], fa[M], dfn[M], son[M], top[M];
void dfs1(int u, int f) {
  de[u] = de[fa[u] = f] + 1;
  sz[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == f) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++num;
  if (son[u]) dfs2(son[u], tp);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
int QUERY(int x, int y) {
  int res = 1e9;
  while (top[x] != top[y]) {
    if (de[top[x]] < de[top[y]]) swap(x, y);
    res = min(res, Query(1, 1, cnt, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (de[x] < de[y]) swap(x, y);
  res = min(res, Query(1, 1, cnt, dfn[y], dfn[x]));
  if (y <= n)
    res = min(res, w[y]);
  else
    res = min(res, w[fa[y]]);
  return res;
}
void CHANGE(int x, int d) {
  nw[fa[x] - n].erase(nw[fa[x] - n].find(w[x]));
  w[x] = d;
  nw[fa[x] - n].insert(w[x]);
  Change(1, 1, cnt, dfn[fa[x]], *nw[fa[x] - n].begin());
}
void Init() {
  dfs1(n + 1, 0), dfs2(n + 1, n + 1);
  Build(1, 1, cnt);
  for (int i = 1; i <= n; i++) nw[fa[i] - n].insert(w[i]);
  for (int i = n + 1; i <= cnt; i++)
    Change(1, 1, cnt, dfn[i], *nw[i - n].begin());
}
}  // namespace ShuPou
using namespace ShuPou;
void solve() {
  n = read(), m = read(), q = read();
  cnt = n;
  w[0] = 1e9;
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    add(x, y), add(y, x);
  }
  YuanFangShu::tarjan(1);
  Init();
  while (q--) {
    char opt[5];
    scanf("%s", opt);
    if (opt[0] == 'C') {
      int x = read(), w = read();
      CHANGE(x, w);
    } else {
      int x = read(), y = read();
      printf("%d\n", QUERY(x, y));
    }
  }
}
signed main() { solve(); }