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 double pi = acos(-1);
struct BCC_tree {
  vector<int> E[220000];
  int size[220000], dfn[220000], up[220000], s[4 * 220000], fa[220000];
  int n, tim;
  void addedge(int x, int y) { E[x].push_back(y); }
  void change(int p, int l, int r, int x, int k) {
    if (l == r) {
      s[p] = k;
      return;
    }
    int mid = (l + r) / 2;
    if (x <= mid)
      change(p * 2, l, mid, x, k);
    else
      change(p * 2 + 1, mid + 1, r, x, k);
    s[p] = min(s[p * 2], s[p * 2 + 1]);
  }
  int calc(int p, int l, int r, int x, int y) {
    if (x <= l && y >= r) return s[p];
    int ans = 1 << 30, mid = (l + r) / 2;
    if (x <= mid) ans = min(ans, calc(p * 2, l, mid, x, y));
    if (y > mid) ans = min(ans, calc(p * 2 + 1, mid + 1, r, x, y));
    return ans;
  }
  void change(int x, int val) { change(1, 1, n, dfn[x], val); }
  pair<int, int> query(int x, int y) {
    int ans = 1 << 30;
    for (;;) {
      if (up[x] == up[y]) {
        if (dfn[x] > dfn[y]) swap(x, y);
        ans = min(ans, calc(1, 1, n, dfn[x], dfn[y]));
        return make_pair(ans, x);
      }
      if (dfn[fa[up[y]]] > dfn[fa[up[x]]]) swap(x, y);
      ans = min(ans, calc(1, 1, n, dfn[up[x]], dfn[x]));
      x = fa[up[x]];
    }
  }
  void getsize(int x) {
    size[x] = 1;
    for (int i : E[x]) {
      getsize(i);
      fa[i] = x;
      size[x] += size[i];
    }
  }
  void dfs(int x) {
    dfn[x] = ++tim;
    int maxx = -1;
    for (int i : E[x])
      if (maxx == -1 || size[i] > size[maxx]) maxx = i;
    if (maxx != -1) {
      up[maxx] = up[x];
      dfs(maxx);
    }
    for (int i : E[x])
      if (i != maxx) {
        up[i] = i;
        dfs(i);
      }
  }
  void prep() {
    getsize(n);
    up[n] = n;
    dfs(n);
  }
} T;
multiset<int> Val[220000];
vector<int> E[220000], E1[220000];
pair<int, int> q[220000];
int low[220000], tim, dfn[220000], M, n, m, Q, be[220000], w[220000], top,
    Fa[220000], cut[220000], id[220000];
void tarjan(int x, int ff) {
  q[++top] = make_pair(ff, x);
  dfn[x] = low[x] = ++tim;
  for (int i : E[x])
    if (i != ff) {
      if (!dfn[i]) {
        tarjan(i, x);
        low[x] = min(low[x], low[i]);
        if (low[i] >= dfn[x]) {
          cut[x] = 1;
          M++;
          for (;;) {
            be[q[top].first] = be[q[top].second] = M;
            top--;
            if (q[top + 1] == make_pair(x, i)) break;
          }
          E1[x].push_back(M);
          Fa[M] = x;
        }
      } else
        low[x] = min(low[x], dfn[i]);
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  tarjan(1, 0);
  for (int i = 2; i <= n; ++i)
    if (cut[i]) cut[i] = ++M, id[M] = i, Val[M].insert(1 << 30);
  cut[1] = be[1] = ++M;
  T.n = M;
  for (int i = 1; i <= n; ++i)
    if (cut[i]) {
      if (i != 1) T.addedge(be[i], cut[i]);
      for (int j : E1[i]) T.addedge(cut[i], j);
    }
  T.prep();
  for (int i = 1; i <= n; ++i) Val[be[i]].insert(w[i]);
  for (int i = 1; i <= M; ++i) T.change(i, *Val[i].begin());
  for (int _ = 1; _ <= Q; ++_) {
    char type[12];
    int x, y;
    scanf("%s%d%d", type, &x, &y);
    if (type[0] == 'A') {
      if (x == y)
        printf("%d\n", w[x]);
      else {
        if (cut[x])
          x = cut[x];
        else
          x = be[x];
        if (cut[y])
          y = cut[y];
        else
          y = be[y];
        pair<int, int> tmp = T.query(x, y);
        if (id[tmp.second])
          tmp.first = min(tmp.first, w[id[tmp.second]]);
        else if (Fa[tmp.second] != 0)
          tmp.first = min(tmp.first, w[Fa[tmp.second]]);
        printf("%d\n", tmp.first);
      }
    } else {
      Val[be[x]].erase(Val[be[x]].find(w[x]));
      Val[be[x]].insert(y);
      w[x] = y;
      T.change(be[x], *Val[be[x]].begin());
    }
  }
}