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 Max = 1e5 + 10;
using namespace std;
struct edge {
  int to;
  int next;
};
multiset<int> point[Max << 1];
vector<int> e[Max], g[Max << 1];
int tree[Max << 3], val[Max << 1];
int dfn[Max << 1], rDfn[Max << 1], low[Max << 1], son[Max << 1], hTop[Max << 1],
    size[Max << 1], fa[Max << 1], dep[Max << 1];
int s[Max];
int cnt = 0, cnt1 = 0, timing = 0, top = -1, all;
int n, m, q;
void dfs(int u) {
  son[u] = 0;
  size[u] = 1;
  for (int v : g[u]) {
    if (!dep[v]) {
      dep[v] = dep[u] + 1;
      fa[v] = u;
      dfs(v);
      size[u] += size[v];
      if (size[v] > size[son[u]]) {
        son[u] = v;
      }
    }
  }
}
void linkCut(int u, int top) {
  hTop[u] = top;
  dfn[u] = ++timing;
  rDfn[timing] = u;
  if (!son[u]) {
    return;
  }
  linkCut(son[u], top);
  for (int v : g[u]) {
    if (v != son[u] && v != fa[u]) {
      linkCut(v, v);
    }
  }
}
void tarjan(int u) {
  low[u] = dfn[u] = ++timing;
  s[++top] = u;
  for (int v : e[u]) {
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        ++all;
        for (int x = 0; x != v; --top) {
          x = s[top];
          g[all].push_back(x);
          g[x].push_back(all);
        }
        g[all].push_back(u);
        g[u].push_back(all);
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
void pushUp(int k) { tree[k] = min(tree[k << 1], tree[k << 1 | 1]); }
void build(int i, int l, int r) {
  if (l == r) {
    tree[i] = val[rDfn[l]];
    return;
  }
  build((i << 1), l, ((l + r) >> 1)),
      build((i << 1 | 1), ((l + r) >> 1) + 1, r);
  tree[i] = std::min(tree[(i << 1)], tree[(i << 1 | 1)]);
}
void update(int i, int l, int r, int p, int x) {
  if (l == r) {
    tree[i] = x;
    return;
  }
  if (p <= ((l + r) >> 1))
    update((i << 1), l, ((l + r) >> 1), p, x);
  else
    update((i << 1 | 1), ((l + r) >> 1) + 1, r, p, x);
  tree[i] = std::min(tree[(i << 1)], tree[(i << 1 | 1)]);
}
int query(int i, int l, int r, int a, int b) {
  if (r < a || b < l) return 0x7fffffff;
  if (a <= l && r <= b) return tree[i];
  return std::min(query((i << 1), l, ((l + r) >> 1), a, b),
                  query((i << 1 | 1), ((l + r) >> 1) + 1, r, a, b));
}
void modify(int u, int x) {
  int mn;
  update(1, 1, all, dfn[u], x);
  if (fa[u]) {
    point[fa[u]].erase(point[fa[u]].lower_bound(val[u]));
    point[fa[u]].insert(x);
    mn = *point[fa[u]].begin();
    if (val[fa[u]] != mn) {
      val[fa[u]] = mn;
      update(1, 1, all, dfn[fa[u]], val[fa[u]]);
    }
  }
  val[u] = x;
}
int solve(int u, int v) {
  int ans = 0x7fffffff;
  while (hTop[u] != hTop[v]) {
    if (dep[hTop[u]] < dep[hTop[v]]) {
      swap(u, v);
    }
    ans = min(ans, query(1, 1, all, dfn[hTop[u]], dfn[u]));
    u = fa[hTop[u]];
  }
  if (dep[u] > dep[v]) {
    swap(u, v);
  }
  ans = min(ans, query(1, 1, all, dfn[u], dfn[v]));
  if (u > n) {
    ans = min(ans, val[fa[u]]);
  }
  return ans;
}
int main() {
  int u, v, k, x, y;
  char op[2];
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", &val[i]);
  all = n;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  tarjan(1);
  dep[1] = 1;
  dfs(1);
  timing = 0;
  linkCut(1, 1);
  for (int i = 1; i <= n; ++i)
    if (fa[i]) point[fa[i]].insert(val[i]);
  for (int i = n + 1; i <= all; ++i) val[i] = *point[i].begin();
  build(1, 1, all);
  for (int i = 1; i <= q; i++) {
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'C') {
      update(1, 1, all, dfn[x], y);
      if (fa[x]) {
        int u = fa[x];
        point[u].erase(point[u].lower_bound(val[x]));
        point[u].insert(y);
        if (val[u] != *point[u].begin()) {
          val[u] = *point[u].begin();
          update(1, 1, all, dfn[u], val[u]);
        }
      }
      val[x] = y;
    } else {
      int ans = 0x7fffffff;
      while (hTop[x] != hTop[y]) {
        if (dep[hTop[x]] < dep[hTop[y]]) swap(x, y);
        ans = min(ans, query(1, 1, all, dfn[hTop[x]], dfn[x]));
        x = fa[hTop[x]];
      }
      if (dfn[x] > dfn[y]) swap(x, y);
      ans = min(ans, query(1, 1, all, dfn[x], dfn[y]));
      if (x > n) ans = min(ans, val[fa[x]]);
      printf("%d\n", ans);
    }
  }
  return 0;
}