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>
const int N = 3e5 + 5, inf = 2e9;
using namespace std;
struct node {
  int x, y;
} q1[N << 1], q2[N << 2];
int k1[N], k2[N], w[N], df[N], lo[N], ansd[N];
int su1, su2, tot, ext, n;
multiset<int> v[N];
stack<int> st;
namespace shupou {
struct node {
  int l, r, mi;
} q[N << 2];
int df[N], dy[N], si[N], er[N], d[N], fa[N], t[N];
int s = 0;
inline void pushup(int x) { q[x].mi = min(q[x << 1].mi, q[(x << 1) | 1].mi); }
void build(int x, int l, int r) {
  q[x].l = l;
  q[x].r = r;
  if (l == r) return (void)(q[x].mi = w[dy[l]]);
  int m = (l + r) >> 1;
  build(x << 1, l, m);
  build((x << 1) | 1, m + 1, r);
  pushup(x);
}
void modify(int x, int l, int r, int y) {
  if (q[x].r < l || r < q[x].l) return;
  if (q[x].l >= l && q[x].r <= r) return (void)(q[x].mi = y);
  modify(x << 1, l, r, y);
  modify((x << 1) | 1, l, r, y);
  pushup(x);
}
int query(int x, int l, int r) {
  if (q[x].r < l || r < q[x].l) return inf;
  if (q[x].l >= l && q[x].r <= r) return q[x].mi;
  return min(query(x << 1, l, r), query((x << 1) | 1, l, r));
}
void dfs1(int x, int f) {
  si[x] = 1;
  for (int i = k2[x]; i; i = q2[i].x) {
    int y = q2[i].y;
    if (y == f) continue;
    d[y] = d[x] + 1;
    fa[y] = x;
    dfs1(y, x);
    si[x] += si[y];
    if (si[er[x]] < si[y]) er[x] = y;
  }
}
void dfs2(int x, int to) {
  df[x] = ++s;
  dy[s] = x;
  t[x] = to;
  if (!er[x]) return;
  dfs2(er[x], to);
  for (int i = k2[x]; i; i = q2[i].x)
    if (!t[q2[i].y]) dfs2(q2[i].y, q2[i].y);
}
inline pair<int, int> ask(int x, int y) {
  int mi = inf;
  while (t[x] != t[y]) {
    if (d[t[x]] < d[t[y]]) swap(x, y);
    mi = min(mi, query(1, df[t[x]], df[x]));
    x = fa[t[x]];
  }
  if (d[x] > d[y]) swap(x, y);
  mi = min(mi, query(1, df[x], df[y]));
  return make_pair(x, mi);
}
}  // namespace shupou
inline int r() {
  char h = getchar();
  int y = 0;
  while (h < '0' || h > '9') h = getchar();
  while (h >= '0' && h <= '9') y = y * 10 + h - '0', h = getchar();
  return y;
}
inline int rrc() {
  char h = getchar();
  while (h != 'A' && h != 'C') h = getchar();
  return h == 'C';
}
inline void jr1(int a, int b) {
  q1[++su1] = (node){k1[a], b};
  k1[a] = su1;
}
inline void jr2(int a, int b) {
  q2[++su2] = (node){k2[a], b};
  k2[a] = su2;
  swap(a, b);
  q2[++su2] = (node){k2[a], b};
  k2[a] = su2;
}
inline void updata(int x) {
  if (v[x - n].empty()) return (void)(w[x] = inf);
  multiset<int>::iterator it = v[x - n].begin();
  w[x] = *it;
}
void tarjan(int x, int fa) {
  st.push(x);
  df[x] = lo[x] = ++tot;
  for (int i = k1[x]; i; i = q1[i].x) {
    int y = q1[i].y;
    if (y == fa) continue;
    if (!df[y]) {
      tarjan(y, x);
      lo[x] = min(lo[x], lo[y]);
      if (lo[y] >= df[x]) {
        ++ext;
        while (st.top() != y) jr2(st.top(), ext), st.pop();
        jr2(st.top(), ext), st.pop();
        jr2(ext, x);
      }
    } else
      lo[x] = min(lo[x], df[y]);
  }
}
signed main() {
  n = ext = r();
  int m = r(), q = r();
  for (int i = 1; i <= n; i++) w[i] = r();
  for (int i = 1; i <= m; i++) {
    int a = r(), b = r();
    jr1(a, b);
    jr1(b, a);
  }
  tarjan(1, 0);
  shupou::dfs1(1, 0);
  shupou::dfs2(1, 1);
  for (int i = 1; i <= n; i++)
    if (shupou::fa[i]) v[shupou::fa[i] - n].insert(w[i]);
  for (int i = n + 1; i <= ext; i++) updata(i);
  shupou::build(1, 1, ext);
  w[0] = inf;
  int cnt = 0;
  while (q--) {
    int h = rrc(), a = r(), b = r();
    if (!h) {
      pair<int, int> ans = shupou::ask(a, b);
      printf("%d\n",
             min(ans.second, ans.first > n ? w[shupou::fa[ans.first]] : inf));
    } else if (w[a] != b) {
      multiset<int>::iterator it;
      int y = shupou::fa[a];
      if (y) {
        it = v[y - n].find(w[a]);
        v[y - n].erase(it);
        v[y - n].insert(b);
        int z = w[y];
        updata(y);
        if (z != w[y]) shupou::modify(1, shupou::df[y], shupou::df[y], w[y]);
      }
      shupou::modify(1, shupou::df[a], shupou::df[a], b);
      w[a] = b;
    }
  }
}