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 maxn = 200001;
int head[maxn], col[maxn], kl, dfn[maxn], val[maxn], low[maxn];
int anss, a[maxn], stac[maxn], num, b[maxn], sz[maxn], cnt[maxn];
int indec, sqr, n, m, x, y, top, ans;
int fa[maxn], dep[maxn], son[maxn], back[maxn], tp[maxn], Q;
struct heapy {
  priority_queue<int> q1, q2;
  int sz;
  void add(int x) {
    q1.push(-x);
    ++sz;
  }
  void del(int x) {
    q2.push(-x);
    --sz;
  }
  int top() {
    while (!q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();
    return -q1.top();
  }
  int pop() {
    while (!q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();
    if (!q1.empty()) q1.pop();
    sz--;
  }
} hp[maxn];
struct line {
  int fr, to, next;
} q[maxn * 2];
vector<int> e[maxn];
void pushline(int f, int t) {
  q[++kl].next = head[f];
  head[f] = kl;
  q[kl].to = t;
}
void tarjan(int x, int fa) {
  ++num;
  stac[++top] = x;
  dfn[x] = low[x] = ++indec;
  for (int p = head[x]; int v = q[p].to; p = q[p].next) {
    if (!dfn[v]) {
      tarjan(v, x);
      low[x] = min(low[x], low[v]);
      if (low[v] == dfn[x]) {
        ++sqr;
        e[sqr].push_back(x);
        e[x].push_back(sqr);
        for (int now = 0; now != v; --top) {
          now = stac[top];
          e[sqr].push_back(now);
          e[now].push_back(sqr);
        }
      }
    } else
      low[x] = min(low[x], dfn[v]);
  }
}
struct seg {
  int l, r, val;
} t[maxn * 4];
void pushup(int x) { t[x].val = min(t[x << 1].val, t[x << 1 | 1].val); }
void build(int x, int l, int r) {
  t[x].l = l;
  t[x].r = r;
  if (l == r) {
    if (back[l] > n)
      t[x].val = hp[back[l]].top();
    else
      t[x].val = val[back[l]];
    return;
  }
  int mid = (l + r) / 2;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}
void change(int x, int pos, int d) {
  if (t[x].l == t[x].r && pos == t[x].l) {
    t[x].val = d;
    return;
  }
  int mid = (t[x].l + t[x].r) / 2;
  if (pos <= mid) change(x << 1, pos, d);
  if (pos > mid) change(x << 1 | 1, pos, d);
  pushup(x);
}
int query(int x, int l, int r) {
  if (l > r) swap(l, r);
  int lx = t[x].l, rx = t[x].r;
  if (l <= lx && r >= rx) return t[x].val;
  int mid = (lx + rx) / 2, ans = 1e9;
  if (l <= mid) ans = query(x << 1, l, r);
  if (r > mid) ans = min(ans, query(x << 1 | 1, l, r));
  return ans;
}
void dfs1(int x, int fat) {
  fa[x] = fat, sz[x] = 1, dep[x] = dep[fat] + 1, son[x] = 0;
  if (x <= n && fa[x]) hp[fa[x]].add(val[x]);
  for (int v : e[x]) {
    if (v == fat) continue;
    dfs1(v, x);
    if (sz[v] > sz[son[x]]) son[x] = v;
    sz[x] += sz[v];
  }
}
void dfs2(int x, int topp) {
  tp[x] = topp;
  dfn[x] = ++indec;
  back[indec] = x;
  if (son[x]) dfs2(son[x], topp);
  for (int v : e[x]) {
    if (v == fa[x] || v == son[x]) continue;
    dfs2(v, v);
  }
}
int treequery(int x, int y) {
  int ans = 1e9;
  while (tp[x] != tp[y]) {
    if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
    ans = min(ans, query(1, dfn[tp[x]], dfn[x]));
    x = fa[tp[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  ans = min(ans, query(1, dfn[x], dfn[y]));
  if (fa[x] <= n && fa[x]) ans = min(ans, val[fa[x]]);
  return ans;
}
char opt[10];
int main() {
  cin >> n >> m >> Q;
  sqr = n;
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &x, &y), pushline(x, y), pushline(y, x);
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, 0);
  indec = 0;
  dfs1(1, 0);
  dfs2(1, 1);
  build(1, 1, sqr);
  while (Q--) {
    scanf("%s%d%d", opt, &x, &y);
    if (opt[0] == 'C') {
      change(1, dfn[x], y);
      int v = fa[x];
      if (v > n) {
        hp[v].del(val[x]);
        hp[v].add(y);
        change(1, dfn[v], hp[v].top());
      }
      val[x] = y;
    } else
      printf("%d\n", treequery(x, y));
  }
}