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;
int n, m;
const int N = 2e5 + 10;
const int M = 4e5 + 10;
int col[N];
struct bain {
  int from, to;
};
struct tree {
  bain eg[N << 1];
  int front[N], num;
  void add(int x, int y) {
    eg[++num].to = y;
    eg[num].from = front[x];
    front[x] = num;
  }
  int ids = 0;
  int siz[N], dfn[N], son[N], dep[N], top[N], fa[N];
  void dfs1(int o, int from) {
    fa[o] = from;
    dep[o] = dep[from] + 1;
    siz[o] = 1;
    for (int i = front[o]; i; i = eg[i].from) {
      int to = eg[i].to;
      if (to == from) continue;
      dfs1(to, o);
      siz[o] += siz[to];
      if (siz[to] > siz[son[o]]) son[o] = to;
    }
  }
  void dfs2(int o, int tp) {
    dfn[o] = ++ids;
    top[o] = tp;
    if (son[o]) dfs2(son[o], tp);
    for (int i = front[o]; i; i = eg[i].from) {
      int to = eg[i].to;
      if (to == fa[o] || to == son[o]) continue;
      dfs2(to, to);
    }
  }
  multiset<int> se[N];
  int mins[N << 2];
  void opt1(int o, int l, int r, int i, int x) {
    if (l == r) {
      mins[o] = x;
      return;
    }
    int mid = (l + r) >> 1;
    if (mid >= i)
      opt1(o << 1, l, mid, i, x);
    else
      opt1(o << 1 | 1, mid + 1, r, i, x);
    mins[o] = min(mins[o << 1], mins[o << 1 | 1]);
  }
  int opt2(int o, int l, int r, int L, int R) {
    if (L <= l && r <= R) return mins[o];
    int mid = (l + r) >> 1, a = 1e9;
    if (mid >= L) a = opt2(o << 1, l, mid, L, R);
    if (mid < R) a = min(opt2(o << 1 | 1, mid + 1, r, L, R), a);
    return a;
  }
  int que(int x, int y) {
    int re = 1e9;
    while (top[x] != top[y]) {
      if (dep[top[x]] < dep[top[y]]) swap(x, y);
      re = min(re, opt2(1, 1, n, dfn[top[x]], dfn[x]));
      x = fa[top[x]];
    }
    if (dep[x] < dep[y]) swap(x, y);
    re = min(re, opt2(1, 1, n, dfn[y], dfn[x]));
    if (col[y]) re = min(re, opt2(1, 1, n, dfn[fa[y]], dfn[fa[y]]));
    return re;
  }
} T;
struct graph {
  bain eg[M << 1];
  int front[N], num;
  void add(int x, int y) {
    eg[++num].to = y;
    eg[num].from = front[x];
    front[x] = num;
  }
  int ids = 0;
  int dfn[N], low[N];
  int st[N];
  int top;
  int tot = 0;
  int dfs(int o) {
    low[o] = dfn[o] = ++ids;
    st[++top] = o;
    for (int i = front[o]; i; i = eg[i].from) {
      int to = eg[i].to;
      if (dfn[to] == 0) {
        low[o] = min(low[o], dfs(to));
        if (dfn[o] <= low[to]) {
          ++n;
          col[n] = 1;
          int now;
          T.add(n, o);
          T.add(o, n);
          do {
            now = st[top--];
            T.add(n, now);
            T.add(now, n);
          } while (now != to);
        }
      } else
        low[o] = min(low[o], dfn[to]);
    }
    return low[o];
  }
} G;
int w[N], q;
int main() {
  scanf("%d%d%d", &n, &m, &q);
  G.tot = n;
  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);
    G.add(x, y);
    G.add(y, x);
  }
  G.dfs(1);
  T.dfs1(1, 0);
  T.dfs2(1, 1);
  for (int i = 1; i <= n; ++i) {
    if (col[i]) {
      for (int j = T.front[i]; j; j = T.eg[j].from) {
        int to = T.eg[j].to;
        if (to != T.fa[i]) T.se[i].insert(w[to]);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (col[i])
      T.opt1(1, 1, n, T.dfn[i], *((T.se[i]).begin()));
    else
      T.opt1(1, 1, n, T.dfn[i], w[i]);
  }
  for (int i = 1; i <= q; ++i) {
    char ss[10];
    int x, y;
    scanf("%s%d%d", &ss, &x, &y);
    if (ss[0] == 'A') {
      printf("%d\n", T.que(x, y));
    } else {
      T.opt1(1, 1, n, T.dfn[x], y);
      if (x != 1) {
        T.se[T.fa[x]].erase(T.se[T.fa[x]].lower_bound(w[x]));
        w[x] = y;
        T.se[T.fa[x]].insert(y);
        T.opt1(1, 1, n, T.dfn[T.fa[x]], *T.se[T.fa[x]].begin());
      }
    }
  }
}