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 = 200005;
multiset<int> st[N];
int n, m, q, i, j, k, w[N], head[N], adj[N * 2], nxt[N * 2], id[N], len, pre[N],
    s[N], top, num, col[N], Head[N], Adj[N * 2], Nxt[N * 2], l, c[N], dep[N],
    son[N], size[N], fa[N], tp[N], h[N], ans, mn[N * 5];
char ch[10];
void addedge(int u, int v) {
  Adj[++l] = v;
  Nxt[l] = Head[u];
  Head[u] = l;
  Adj[++l] = u;
  Nxt[l] = Head[v];
  Head[v] = l;
}
void dfs(int x, int dad) {
  id[x] = pre[x] = ++len;
  for (int y = head[x]; y; y = nxt[y])
    if (!id[adj[y]]) {
      s[++top] = (y + 1) / 2;
      dfs(adj[y], x);
      pre[x] = min(pre[x], pre[adj[y]]);
      if (pre[adj[y]] >= id[x]) {
        ++num;
        while (1) {
          if (col[adj[s[top] * 2 - 1]] != num) {
            addedge(adj[s[top] * 2 - 1], n + num);
            col[adj[s[top] * 2 - 1]] = num;
          }
          if (col[adj[s[top] * 2]] != num) {
            addedge(adj[s[top] * 2], n + num);
            col[adj[s[top] * 2]] = num;
          }
          --top;
          if (s[top + 1] == (y + 1) / 2) break;
        }
      }
    } else if (adj[y] != dad && id[adj[y]] < pre[x]) {
      s[++top] = (y + 1) / 2;
      pre[x] = id[adj[y]];
    }
}
void Dfs(int x, int dad) {
  size[x] = 1;
  for (int y = Head[x]; y; y = Nxt[y])
    if (Adj[y] != dad) {
      dep[Adj[y]] = dep[x] + 1;
      fa[Adj[y]] = x;
      Dfs(Adj[y], x);
      size[x] += size[Adj[y]];
      if (!son[x] || size[Adj[y]] > size[son[x]]) son[x] = Adj[y];
    }
}
void work(int x, int dad) {
  c[x] = ++i;
  h[i] = x;
  if (son[x]) {
    tp[son[x]] = tp[x];
    work(son[x], x);
  }
  for (int y = Head[x]; y; y = Nxt[y])
    if (Adj[y] != dad && Adj[y] != son[x]) {
      tp[Adj[y]] = Adj[y];
      work(Adj[y], x);
    }
}
void built(int o, int l, int r) {
  if (l == r) {
    mn[o] = (h[l] <= n ? w[h[l]] : *(st[h[l]].begin()));
    return;
  }
  int mid = l + r >> 1;
  built(o << 1, l, mid);
  built(o << 1 | 1, mid + 1, r);
  mn[o] = min(mn[o << 1], mn[o << 1 | 1]);
}
void update(int o, int l, int r, int x, int y) {
  if (l == r) {
    mn[o] = y;
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid)
    update(o << 1, l, mid, x, y);
  else
    update(o << 1 | 1, mid + 1, r, x, y);
  mn[o] = min(mn[o << 1], mn[o << 1 | 1]);
}
int query(int o, int l, int r, int x, int y) {
  if (l >= x && r <= y) return mn[o];
  int mid = l + r >> 1, rtn = 1 << 30;
  if (x <= mid) rtn = query(o << 1, l, mid, x, y);
  if (y > mid) rtn = min(rtn, query(o << 1 | 1, mid + 1, r, x, y));
  return rtn;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; ++i) scanf("%d", w + i);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &j, &k);
    adj[i * 2 - 1] = k;
    nxt[i * 2 - 1] = head[j];
    head[j] = i * 2 - 1;
    adj[i * 2] = j;
    nxt[i * 2] = head[k];
    head[k] = i * 2;
  }
  for (i = 1; i <= n; ++i)
    if (!id[i]) dfs(i, -1);
  Dfs(1, -1);
  tp[1] = 1;
  i = 0;
  work(1, -1);
  for (i = 1; i <= n; ++i)
    if (fa[i]) st[fa[i]].insert(w[i]);
  built(1, 1, n + num);
  while (q--) {
    scanf("%s%d%d", ch, &i, &j);
    if (ch[0] == 'C') {
      update(1, 1, n + num, c[i], j);
      if (fa[i]) {
        st[fa[i]].erase(st[fa[i]].find(w[i]));
        st[fa[i]].insert(j);
        update(1, 1, n + num, c[fa[i]], *(st[fa[i]].begin()));
      }
      w[i] = j;
    } else {
      ans = 1 << 30;
      while (tp[i] != tp[j]) {
        if (dep[tp[i]] < dep[tp[j]]) swap(i, j);
        ans = min(ans, query(1, 1, n + num, c[tp[i]], c[i]));
        i = fa[tp[i]];
      }
      if (dep[i] > dep[j]) swap(i, j);
      ans = min(ans, query(1, 1, n + num, c[i], c[j]));
      if (i > n && fa[i]) ans = min(ans, w[fa[i]]);
      printf("%d\n", ans);
    }
  }
  return 0;
}