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 inf = 0x3f3f3f3f;
int n, m, q, FANG;
int a[200010], b[200010];
int dfn[100010], low[100010], sta[100010], statop, dfs_clock;
int lastG[100010], lastT[200010], numG, numT;
int fa[200010], size[200010], top[200010], dep[200010], son[200010], id[200010],
    _id[200010];
multiset<int> w[200010];
char str[10];
struct EDGE {
  int ver, next;
} edgeG[200010], edgeT[400010];
struct SegmentTree {
  int l, r, Min;
} st[800010];
inline int read() {
  int x = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -x : x;
}
void addG(int U, int V) {
  edgeG[++numG] = (EDGE){V, lastG[U]};
  lastG[U] = numG;
}
void addT(int U, int V) {
  edgeT[++numT] = (EDGE){V, lastT[U]};
  lastT[U] = numT;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++dfs_clock;
  sta[++statop] = x;
  for (int i = lastG[x], y = edgeG[i].ver; i;
       i = edgeG[i].next, y = edgeG[i].ver)
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (dfn[x] <= low[y]) {
        ++FANG;
        for (; sta[statop] != y; statop--) {
          addT(FANG, sta[statop]);
          addT(sta[statop], FANG);
        }
        statop--;
        addT(y, FANG);
        addT(FANG, y);
        addT(x, FANG);
        addT(FANG, x);
      }
    } else
      low[x] = min(low[x], dfn[y]);
}
void dfs(int x, int F) {
  size[x] = 1;
  for (int i = lastT[x], y = edgeT[i].ver; i;
       i = edgeT[i].next, y = edgeT[i].ver) {
    if (y == F) continue;
    dep[y] = dep[fa[y] = x] + 1;
    dfs(y, x);
    size[x] += size[y];
    if (size[y] > size[son[x]]) son[x] = y;
  }
}
void dfs(int x, int F, int Top) {
  top[_id[id[x] = ++dfs_clock] = x] = Top;
  b[dfs_clock] = a[x];
  if (!son[x]) return;
  dfs(son[x], x, Top);
  for (int i = lastT[x], y = edgeT[i].ver; i;
       i = edgeT[i].next, y = edgeT[i].ver) {
    if (y == F || y == son[x]) continue;
    dfs(y, x, y);
  }
}
int lca(int x, int y) {
  while (top[x] ^ top[y])
    dep[top[x]] >= dep[top[y]] ? x = fa[top[x]] : y = fa[top[y]];
  return dep[x] < dep[y] ? x : y;
}
void build(int p, int l, int r) {
  st[p].l = l;
  st[p].r = r;
  if (l == r) return st[p].Min = b[l], void();
  int mid = (st[p].l + st[p].r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  st[p].Min = min(st[p << 1].Min, st[p << 1 | 1].Min);
}
void change(int p, int pos, int val) {
  if (st[p].l == st[p].r) return st[p].Min = val, void();
  int mid = (st[p].l + st[p].r) >> 1;
  if (pos <= mid)
    change(p << 1, pos, val);
  else
    change(p << 1 | 1, pos, val);
  st[p].Min = min(st[p << 1].Min, st[p << 1 | 1].Min);
}
int ask(int p, int l, int r) {
  if (l <= st[p].l && st[p].r <= r) return st[p].Min;
  int mid = (st[p].l + st[p].r) >> 1, Min = inf;
  if (l <= mid) Min = ask(p << 1, l, r);
  if (mid < r) Min = min(Min, ask(p << 1 | 1, l, r));
  return Min;
}
int ask(int x, int y) {
  int Min = inf;
  while (top[x] ^ top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    Min = min(Min, ask(1, id[top[x]], id[x]));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x > n) Min = min(Min, a[fa[x]]);
  return min(Min, ask(1, id[x], id[y]));
}
int main() {
  FANG = n = read();
  m = read();
  q = read();
  memset(a, 0x3f, sizeof a);
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    addG(x, y);
    addG(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  dfs_clock = 0;
  for (int i = 1; i <= FANG; i++)
    if (!size[i]) {
      dfs(i, 0);
      dfs(i, 0, i);
    }
  build(1, 1, FANG);
  for (int i = 1; i <= n; i++) {
    w[fa[i]].insert(a[i]);
    change(1, id[fa[i]], *w[fa[i]].begin());
  }
  while (q-- > 0) {
    scanf("%s", str + 1);
    if (str[1] == 'C') {
      int x = read(), val = read();
      w[fa[x]].erase(w[fa[x]].lower_bound(a[x]));
      w[fa[x]].insert(a[x] = val);
      change(1, id[x], val);
      change(1, id[fa[x]], *w[fa[x]].begin());
    } else
      printf("%d\n", ask(read(), read()));
  }
}