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 = 5e5 + 5, INF = 2e9 + 7;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m;
vector<int> e1[N], e[N];
int dfn[N], low[N], lead, stk[N], tp, ext, dep[N], top[N], seg[N], rev[N],
    sze[N], fa[N], son[N], val[N];
void link(int u, int v) {
  e[u].push_back(v);
  e[v].push_back(u);
}
int min(int x, int y) { return x < y ? x : y; }
void swap(int &x, int &y) {
  int t = x;
  x = y;
  y = t;
}
struct Heap {
  priority_queue<int> Del, q;
  void push(int x) { q.push(-x); }
  void del(int x) { Del.push(-x); }
  int top() {
    while (!q.empty() && !Del.empty() && q.top() == Del.top())
      q.pop(), Del.pop();
    return -q.top();
  }
} H[N];
void dfs(int u, int fa) {
  dfn[u] = low[u] = ++lead;
  stk[++tp] = u;
  for (int i = e1[u].size() - 1; i >= 0; --i) {
    int v = e1[u][i];
    if (!dfn[v]) {
      dfs(v, u);
      low[u] = min(low[v], low[u]);
      if (low[v] == dfn[u]) {
        val[++ext] = INF;
        int y = 0;
        while (y != v) {
          y = stk[tp--];
          link(ext, y);
        }
        link(ext, u);
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
void df5(int u, int fat) {
  sze[u] = 1;
  dep[u] = dep[fat] + 1;
  fa[u] = fat;
  val[fat] = min(val[fat], val[u]);
  H[fat].push(val[u]);
  for (int i = e[u].size() - 1; i >= 0; --i) {
    int v = e[u][i];
    if (v == fat) continue;
    df5(v, u);
    sze[u] += sze[v];
    if (sze[v] > sze[son[u]]) son[u] = v;
  }
}
void dfS(int u) {
  if (son[u]) {
    int v = son[u];
    seg[v] = ++lead;
    rev[lead] = v;
    top[v] = top[u];
    dfS(v);
  }
  for (int i = e[u].size() - 1; i >= 0; --i) {
    int v = e[u][i];
    if (!top[v]) {
      top[v] = v;
      seg[v] = ++lead;
      rev[lead] = v;
      dfS(v);
    }
  }
}
int mn[N << 2];
void pushup(int i) { mn[i] = min(mn[(i << 1)], mn[(i << 1 | 1)]); }
void build(int i, int l, int r) {
  if (l == r) {
    mn[i] = val[rev[l]];
    return;
  }
  build((i << 1), l, ((l + r) >> 1));
  build((i << 1 | 1), ((l + r) >> 1) + 1, r);
  pushup(i);
}
void updata(int i, int l, int r, int pos, int k) {
  if (l == r) {
    mn[i] = k;
    return;
  }
  if (pos <= ((l + r) >> 1))
    updata((i << 1), l, ((l + r) >> 1), pos, k);
  else
    updata((i << 1 | 1), ((l + r) >> 1) + 1, r, pos, k);
  pushup(i);
}
int query(int i, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[i];
  int res = INF;
  if (x <= ((l + r) >> 1))
    res = min(res, query((i << 1), l, ((l + r) >> 1), x, y));
  if (y > ((l + r) >> 1))
    res = min(res, query((i << 1 | 1), ((l + r) >> 1) + 1, r, x, y));
  return res;
}
int ask(int x, int y) {
  int fx = top[x], fy = top[y];
  int res = INF;
  while (fx != fy) {
    if (dep[fx] < dep[fy]) swap(fx, fy), swap(x, y);
    res = min(res, query(1, 1, ext, seg[fx], seg[x]));
    x = fa[fx];
    fx = top[x];
  }
  if (dep[x] < dep[y]) swap(x, y);
  res = min(res, query(1, 1, ext, seg[y], seg[x]));
  if (y > n) res = min(res, val[fa[y]]);
  return res;
}
int Q;
int main() {
  n = read();
  m = read();
  Q = read();
  ext = n;
  for (int i = 1; i <= n; ++i) val[i] = read();
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    e1[u].push_back(v);
    e1[v].push_back(u);
  }
  lead = 0;
  dfs(1, 0);
  df5(1, 0);
  rev[1] = seg[1] = top[1] = lead = 1;
  dfS(1);
  build(1, 1, ext);
  char opt[4];
  int a, b;
  while (Q--) {
    scanf("%s", opt);
    a = read();
    b = read();
    if (opt[0] == 'C') {
      H[fa[a]].del(val[a]);
      val[a] = b;
      updata(1, 1, ext, seg[a], b);
      H[fa[a]].push(val[a]);
      if (H[fa[a]].top() != val[fa[a]]) {
        val[fa[a]] = H[fa[a]].top();
        updata(1, 1, ext, seg[fa[a]], val[fa[a]]);
      }
    } else
      printf("%d\n", ask(a, b));
  }
  return 0;
}