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;
bool ks;
int n, m, q, FANG;
int dfn[100010], low[100010], dfs_clock, a[200010], b[200010];
int X[200010], Y[200010];
int sta[100010], sttop;
multiset<int> w[200010];
int fa[200010], si_ze[200010], dep[200010], id[200010], top[200010],
    son[200010];
vector<int> G[100010], T[200010];
char opt[10];
struct SegmentTree {
  int l, r, minn;
} st[800010];
bool js;
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 tarjan(int x) {
  dfn[x] = low[x] = ++dfs_clock;
  sta[++sttop] = x;
  for (int i = 0, y = G[x][0], End = G[x].size(); i < End; y = G[x][++i]) {
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (dfn[x] <= low[y]) {
        ++FANG;
        for (; sta[sttop] != y; sttop--) {
          T[FANG].push_back(sta[sttop]);
          T[sta[sttop]].push_back(FANG);
        }
        sttop--;
        T[FANG].push_back(y);
        T[y].push_back(FANG);
        T[FANG].push_back(x);
        T[x].push_back(FANG);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
void dfs(int x, int F) {
  si_ze[x] = 1;
  for (int i = 0, y = T[x][0], End = T[x].size(); i < End; y = T[x][++i]) {
    if (y == F) continue;
    dep[y] = dep[fa[y] = x] + 1;
    dfs(y, x);
    si_ze[x] += si_ze[y];
    if (si_ze[y] > si_ze[son[x]]) son[x] = y;
  }
}
void dfs(int x, int F, int Top) {
  b[id[x] = ++dfs_clock] = a[x];
  top[x] = Top;
  if (!son[x]) return;
  dfs(son[x], x, Top);
  for (int i = 0, y = T[x][0], End = T[x].size(); i < End; y = T[x][++i]) {
    if (y == F || y == son[x]) continue;
    dfs(y, x, y);
  }
}
void build(int p, int l, int r) {
  st[p].l = l;
  st[p].r = r;
  if (l == r) return void(st[p].minn = b[l]);
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  st[p].minn = min(st[p << 1].minn, st[p << 1 | 1].minn);
}
int ask(int p, int l, int r) {
  if (l <= st[p].l && st[p].r <= r) return st[p].minn;
  int mid = (st[p].l + st[p].r) >> 1, temp = 0x3f3f3f3f;
  if (l <= mid) temp = min(temp, ask(p << 1, l, r));
  if (mid < r) temp = min(temp, ask(p << 1 | 1, l, r));
  return temp;
}
void change(int p, int pos, int x) {
  if (st[p].l == st[p].r) return void(st[p].minn = x);
  int mid = (st[p].l + st[p].r) >> 1;
  if (pos <= mid)
    change(p << 1, pos, x);
  else
    change(p << 1 | 1, pos, x);
  st[p].minn = min(st[p << 1].minn, st[p << 1 | 1].minn);
}
int ask(int x, int y) {
  int temp = 0x3f3f3f3f;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    temp = min(temp, ask(1, id[top[x]], id[x]));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x > n) temp = min(temp, a[fa[x]]);
  return min(temp, ask(1, id[x], id[y]));
}
int main() {
  FANG = n = read();
  m = read();
  q = read();
  dfs_clock = 0;
  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();
    X[i] = x;
    Y[i] = y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(1), sttop = 0;
  dfs_clock = 0;
  for (int i = 1; i <= FANG; i++)
    if (!si_ze[i]) {
      dfs(i, 0);
      dfs(i, 0, i);
    }
  build(1, 1, FANG);
  for (int x = 1; x <= n; x++) {
    w[fa[x]].insert(a[x]);
    change(1, id[fa[x]], *w[fa[x]].begin());
  }
  while (q-- > 0) {
    scanf("%s", opt + 1);
    if (opt[1] == 'A')
      printf("%d\n", ask(read(), read()));
    else {
      int x = read(), z = read();
      change(1, id[x], z);
      multiset<int>::iterator it = w[fa[x]].find(a[x]);
      w[fa[x]].erase(it);
      w[fa[x]].insert(z);
      change(1, id[fa[x]], *w[fa[x]].begin());
      a[x] = z;
    }
  }
  return 0;
}