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 N = 200010;
struct edge {
  int x, nex;
} e[N * 4];
multiset<int> s[N];
vector<int> E[N];
int dfn[N], low[N], stk[N], bl[N], first[N], a[N];
int mn[N * 4], dep[N], fa[N], sz[N], son[N], top[N];
int ti, n, m, q, x, y, tp, cnt, tot;
char op[3];
void add(int x, int y) {
  e[++tot] = (edge){y, first[x]};
  first[x] = tot;
}
void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++ti;
  stk[++tp] = x;
  for (int i = 0; i < (int)E[x].size(); i++)
    if (!dfn[E[x][i]]) {
      tarjan(E[x][i], x);
      low[x] = min(low[x], low[E[x][i]]);
      if (low[E[x][i]] >= dfn[x]) {
        cnt++;
        do {
          y = stk[tp--];
          bl[y] = cnt;
          add(cnt, y);
          s[cnt].insert(a[y]);
        } while (y != E[x][i]);
        add(x, cnt);
      }
    } else if (E[x][i] != fa)
      low[x] = min(low[x], dfn[E[x][i]]);
}
void dfs1(int x, int y) {
  dep[x] = dep[y] + 1;
  fa[x] = y;
  sz[x] = 1;
  for (int i = first[x]; i; i = e[i].nex) {
    dfs1(e[i].x, x);
    sz[x] += sz[e[i].x];
    if (sz[e[i].x] > sz[son[x]]) son[x] = e[i].x;
  }
}
void dfs2(int x, int y) {
  dfn[x] = ++ti;
  top[x] = y;
  if (son[x]) dfs2(son[x], y);
  for (int i = first[x]; i; i = e[i].nex)
    if (e[i].x != son[x]) dfs2(e[i].x, e[i].x);
}
void modify(int k, int l, int r, int x, int y) {
  if (l == r) {
    mn[k] = y;
    return;
  }
  int mid = (r + l) >> 1;
  if (x <= mid)
    modify(k * 2, l, mid, x, y);
  else
    modify(k * 2 + 1, mid + 1, r, x, y);
  mn[k] = min(mn[k * 2], mn[k * 2 + 1]);
}
int query(int k, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return mn[k];
  int mid = (l + r) >> 1, tmp = 1e9;
  if (ql <= mid) tmp = min(tmp, query(k * 2, l, mid, ql, qr));
  if (qr > mid) tmp = min(tmp, query(k * 2 + 1, mid + 1, r, ql, qr));
  return tmp;
}
void modify(int x, int y) {
  if (bl[x]) {
    s[bl[x]].erase(s[bl[x]].find(a[x]));
    s[bl[x]].insert(y);
    modify(1, 1, ti, dfn[bl[x]], *s[bl[x]].begin());
  }
  a[x] = y;
  modify(1, 1, ti, dfn[x], y);
}
int query(int x, int y) {
  int tmp = 1e9;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    tmp = min(tmp, query(1, 1, ti, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (dep[x] < dep[y]) swap(x, y);
  tmp = min(tmp, query(1, 1, ti, dfn[y], dfn[x]));
  if (y > n && fa[y]) tmp = min(tmp, a[fa[y]]);
  return tmp;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  cnt = n;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  tarjan(1, 0);
  ti = 0;
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++) modify(1, 1, ti, dfn[i], a[i]);
  for (int i = n + 1; i <= ti; i++) modify(1, 1, ti, dfn[i], *s[i].begin());
  for (int i = 1; i <= q; i++) {
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'C')
      modify(x, y);
    else
      printf("%d\n", query(x, y));
  }
  return 0;
}