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 maxn = 2e5 + 10;
const int maxm = 1e5 + 10;
int n, m, Q, cnt_edge, num;
int head[maxn], val[maxn];
multiset<int> s[maxn];
struct edge {
  int to, nxt;
} e[maxm << 1];
inline int read() {
  char c = getchar();
  int res = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * f;
}
inline void add_edge(int u, int v) {
  e[++cnt_edge].nxt = head[u];
  head[u] = cnt_edge;
  e[cnt_edge].to = v;
}
namespace Tree {
int cnt_edge, tim;
int head[maxn], size[maxn], pre[maxn], dep[maxn], son[maxn], top[maxn],
    dfn[maxn], pos[maxn];
struct edge {
  int to, nxt;
} e[maxn << 1];
inline void add_edge(int u, int v) {
  e[++cnt_edge].nxt = head[u];
  head[u] = cnt_edge;
  e[cnt_edge].to = v;
}
void dfs1(int x, int fa) {
  size[x] = 1;
  dep[x] = dep[fa] + 1;
  pre[x] = fa;
  if (x <= n && fa) s[fa].insert(val[x]);
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y == fa) continue;
    dfs1(y, x);
    size[x] += size[y];
    if (size[y] > size[son[x]]) son[x] = y;
  }
}
void dfs2(int x, int tp) {
  dfn[x] = ++tim;
  pos[tim] = x;
  top[x] = tp;
  if (son[x]) dfs2(son[x], tp);
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y == pre[x] || y == son[x]) continue;
    dfs2(y, y);
  }
}
int minn[maxn << 2];
inline void up(int p) { minn[p] = min(minn[(p << 1)], minn[(p << 1 | 1)]); }
void build(int p, int l, int r) {
  if (l == r) {
    minn[p] = val[pos[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build((p << 1), l, mid);
  build((p << 1 | 1), mid + 1, r);
  up(p);
}
void change(int p, int l, int r, int pos, int k) {
  if (l == r) {
    minn[p] = k;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    change((p << 1), l, mid, pos, k);
  else
    change((p << 1 | 1), mid + 1, r, pos, k);
  up(p);
}
int query(int p, int l, int r, int ql, int qr) {
  if (l >= ql && r <= qr) return minn[p];
  int mid = (l + r) >> 1, res = 1e9;
  if (ql <= mid) res = min(res, query((p << 1), l, mid, ql, qr));
  if (qr > mid) res = min(res, query((p << 1 | 1), mid + 1, r, ql, qr));
  return res;
}
inline void change(int x, int k) {
  if (pre[x]) {
    s[pre[x]].erase(s[pre[x]].find(val[x]));
    s[pre[x]].insert(k);
    change(1, 1, num, dfn[pre[x]], *s[pre[x]].begin());
  }
  val[x] = k;
  change(1, 1, num, dfn[x], val[x]);
}
inline int query(int x, int y) {
  int res = 1e9;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    res = min(res, query(1, 1, num, dfn[top[x]], dfn[x]));
    x = pre[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  res = min(res, query(1, 1, num, dfn[x], dfn[y]));
  if (x <= n)
    return res;
  else
    return min(res, val[pre[x]]);
}
}  // namespace Tree
int tim, top;
int dfn[maxn], low[maxn], sta[maxn];
void tarjan(int x) {
  dfn[x] = low[x] = ++tim;
  sta[++top] = x;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (dfn[x] == low[y]) {
        num++;
        Tree::add_edge(num, x), Tree::add_edge(x, num);
        int z;
        do {
          z = sta[top--];
          Tree::add_edge(num, z), Tree::add_edge(z, num);
        } while (z != y);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
int main() {
  num = n = read(), m = read(), Q = read();
  val[0] = 1e9;
  for (int i = 1; i <= n; i++) val[i] = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    add_edge(u, v);
    add_edge(v, u);
  }
  tarjan(1);
  Tree::dfs1(1, 0);
  Tree::dfs2(1, 1);
  for (int i = n + 1; i <= num; i++) val[i] = *s[i].begin();
  Tree::build(1, 1, num);
  while (Q--) {
    char op[5];
    scanf("%s", op);
    int x = read(), y = read();
    if (op[0] == 'C')
      Tree::change(x, y);
    else
      printf("%d\n", Tree::query(x, y));
  }
  return 0;
}