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 mx = 1000100;
struct node {
  int nxt, to;
} a[mx * 2];
multiset<int> s[mx];
vector<int> v[mx];
int fa[mx], siz[mx], dep[mx], f[mx << 2], w[mx], low[mx], dfn[mx], h[mx],
    st[mx], son[mx], top[mx], In[mx], seg[mx];
int n, m, x, y, sz, tot, q, tim, cnt;
char op[5];
void add(int x, int y) {
  a[++tot] = (node){h[x], y};
  h[x] = tot;
  a[++tot] = (node){h[y], x};
  h[y] = tot;
}
int read() {
  int f = 0, c = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') c = -1;
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    f = f * 10 + ch - '0';
    ch = getchar();
  }
  return c * f;
}
void tarjan(int x) {
  st[++cnt] = x;
  dfn[x] = low[x] = ++tim;
  for (int i = 0; i < v[x].size(); ++i) {
    int y = v[x][i];
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        add(x, ++sz);
        int z;
        do {
          z = st[cnt--];
          add(z, sz);
        } while (y != z);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
void dfs1(int x, int f) {
  fa[x] = f;
  siz[x] = 1;
  dep[x] = dep[f] + 1;
  for (int i = h[x]; i; i = a[i].nxt) {
    int y = a[i].to;
    if (y == f) continue;
    dfs1(y, x);
    siz[x] += siz[y];
    if (siz[y] > siz[son[x]]) son[x] = y;
  }
}
void dfs2(int x, int tp) {
  top[x] = tp;
  In[x] = ++tim;
  seg[tim] = x;
  if (x <= n) s[fa[x]].insert(w[x]);
  if (son[x]) dfs2(son[x], tp);
  for (int i = h[x]; i; i = a[i].nxt) {
    int y = a[i].to;
    if (y == fa[x] || y == son[x]) continue;
    dfs2(y, y);
  }
  if (x > n) w[x] = *s[x].begin();
}
void modify(int o, int l, int r, int x) {
  if (l == r) {
    f[o] = w[seg[x]];
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    modify((o << 1), l, mid, x);
  else
    modify((o << 1 | 1), mid + 1, r, x);
  f[o] = min(f[(o << 1)], f[(o << 1 | 1)]);
}
int ask(int o, int l, int r, int x, int y) {
  if (x <= l && y >= r) return f[o];
  int mid = (l + r) >> 1, ans = 1e9;
  if (x <= mid) ans = min(ans, ask((o << 1), l, mid, x, y));
  if (y > mid) ans = min(ans, ask((o << 1 | 1), mid + 1, r, x, y));
  return ans;
}
int find(int x, int y) {
  int ans = 2e9;
  for (; top[x] != top[y]; x = fa[top[x]]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ans = min(ans, ask(1, 1, cnt, In[top[x]], In[x]));
  }
  if (dep[x] < dep[y]) swap(x, y);
  ans = min(ans, ask(1, 1, cnt, In[y], In[x]));
  if (y > n) return min(ans, w[fa[y]]);
  return ans;
}
int main() {
  n = read();
  m = read();
  q = read();
  sz = n;
  for (int i = 1; i <= n; ++i) w[i] = read();
  for (int i = 1; i <= m; ++i) {
    x = read();
    y = read();
    v[x].push_back(y);
    v[y].push_back(x);
  }
  tarjan(1);
  tim = cnt = 0;
  dfs1(1, 0);
  dfs2(1, 1);
  cnt = tim;
  for (int i = 1; i <= cnt; ++i) modify(1, 1, cnt, In[i]);
  while (q--) {
    scanf("%s", op);
    x = read();
    y = read();
    if (op[0] == 'C') {
      multiset<int>::iterator it = s[fa[x]].lower_bound(w[x]);
      s[fa[x]].erase(it);
      s[fa[x]].insert(y);
      w[x] = y;
      w[fa[x]] = *s[fa[x]].begin();
      modify(1, 1, cnt, In[x]);
      modify(1, 1, cnt, In[fa[x]]);
    } else
      printf("%d\n", find(x, y));
  }
  return 0;
}