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;
struct data {
  int x, y;
} t[800001];
int n, m, k, x, y, sum, cnt, tot, h[400001], st[400001], f[400001], fa[400001],
    p[400001], idfn[400001], dfn[400001], low[400001], son[400001], dep[400001],
    sz[400001], tr[1600001];
char ch[11];
vector<int> v[400001];
multiset<int> q[400001];
void add(int a, int b) {
  cnt++;
  t[cnt].x = b;
  t[cnt].y = h[a];
  h[a] = cnt;
}
void tarjan(int a) {
  cnt++;
  dfn[a] = cnt;
  low[a] = cnt;
  tot++;
  st[tot] = a;
  for (int i = h[a]; i; i = t[i].y) {
    if (!dfn[t[i].x]) {
      tarjan(t[i].x);
      low[a] = min(low[a], low[t[i].x]);
      if (low[t[i].x] >= dfn[a]) {
        sum++;
        v[sum].push_back(a);
        v[a].push_back(sum);
        int c;
        do {
          c = st[tot];
          tot--;
          v[sum].push_back(c);
          v[c].push_back(sum);
        } while (c != t[i].x);
      }
    } else {
      low[a] = min(low[a], dfn[t[i].x]);
    }
  }
}
void dfs1(int a) {
  sz[a] = 1;
  for (int i = h[a]; i; i = t[i].y) {
    if (t[i].x == fa[a]) continue;
    fa[t[i].x] = a;
    dep[t[i].x] = dep[a] + 1;
    dfs1(t[i].x);
    if (sz[son[a]] < sz[t[i].x]) son[a] = t[i].x;
    sz[a] = sz[a] + sz[t[i].x];
  }
}
void dfs2(int a, int c) {
  cnt++;
  dfn[a] = cnt;
  idfn[cnt] = a;
  p[a] = c;
  if (son[a]) dfs2(son[a], c);
  for (int i = h[a]; i; i = t[i].y) {
    if (t[i].x == fa[a]) continue;
    if (t[i].x == son[a]) continue;
    dfs2(t[i].x, t[i].x);
  }
}
void build(int a, int l, int r) {
  if (l == r) {
    tr[a] = f[idfn[l]];
    return;
  }
  int mid = (l + r) / 2;
  build(a * 2, l, mid);
  build(a * 2 + 1, mid + 1, r);
  tr[a] = min(tr[a * 2], tr[a * 2 + 1]);
}
void turn(int a, int l, int r, int u, int v) {
  if (l > u || r < u) return;
  if (l == r) {
    tr[a] = v;
    return;
  }
  int mid = (l + r) / 2;
  turn(a * 2, l, mid, u, v);
  turn(a * 2 + 1, mid + 1, r, u, v);
  tr[a] = min(tr[a * 2], tr[a * 2 + 1]);
}
int find(int a, int l, int r, int ql, int qr) {
  if (l > qr || r < ql) return 1000000000;
  if (ql <= l && r <= qr) return tr[a];
  int mid = (l + r) / 2;
  int p1 = find(a * 2, l, mid, ql, qr);
  int p2 = find(a * 2 + 1, mid + 1, r, ql, qr);
  return min(p1, p2);
}
int solve(int a, int b) {
  int s = 1000000000;
  while (p[a] != p[b]) {
    if (dep[p[a]] > dep[p[b]]) swap(a, b);
    s = min(s, find(1, 1, sum, dfn[p[b]], dfn[b]));
    b = fa[p[b]];
  }
  if (dep[a] > dep[b]) swap(a, b);
  s = min(s, find(1, 1, sum, dfn[a], dfn[b]));
  if (a > n) s = min(s, f[fa[a]]);
  return s;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  cnt = 0;
  sum = n;
  tarjan(1);
  cnt = 0;
  for (int i = 1; i <= n; i++) h[i] = 0;
  for (int i = 1; i <= sum; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      add(i, v[i][j]);
    }
  }
  cnt = 0;
  dfs1(1);
  dfs2(1, 1);
  for (int i = n + 1; i <= sum; i++) {
    for (int j = h[i]; j; j = t[j].y) {
      if (t[j].x == fa[i]) continue;
      q[i].insert(f[t[j].x]);
    }
    f[i] = *q[i].begin();
  }
  build(1, 1, sum);
  for (int i = 1; i <= k; i++) {
    scanf("%s%d%d", ch + 1, &x, &y);
    if (ch[1] == 'C') {
      if (fa[x] > n) {
        q[fa[x]].erase(q[fa[x]].find(f[x]));
        q[fa[x]].insert(y);
        turn(1, 1, sum, dfn[fa[x]], *q[fa[x]].begin());
      }
      f[x] = y;
      turn(1, 1, sum, dfn[x], y);
    } else {
      printf("%d\n", solve(x, y));
    }
  }
}