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 INF = 1e9;
set<int> fang[400001];
map<int, int> cishu[400001];
int n, m, q, to1[400001], Nxt[400001], first1[400001], dfn[400001], low[400001];
int to[500001], nxt[500001], first[500001], cnt, e1, x2, fa[400001];
int sum, tot = 0, ss[400001], heavy[400001], siz[400001], seg[1000001];
int pos[400001], top[400001], deep[400001], h = 0, Stack[400001 * 10];
char ch;
void Build(int x, int y) {
  to1[cnt] = y;
  Nxt[cnt] = first1[x];
  first1[x] = cnt++;
}
void insert(int x, int y) {
  to[e1] = y;
  nxt[e1] = first[x];
  first[x] = e1++;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++tot;
  Stack[++h] = x;
  for (int i = first1[x]; i != -1; i = Nxt[i])
    if (!dfn[to1[i]]) {
      tarjan(to1[i]);
      low[x] = min(low[x], low[to1[i]]);
      if (dfn[x] <= low[to1[i]]) {
        int z;
        sum++;
        do {
          z = Stack[h--];
          insert(sum, z);
          insert(z, sum);
        } while (z != to1[i]);
        insert(sum, x);
        insert(x, sum);
      }
    } else
      low[x] = min(low[x], dfn[to1[i]]);
}
void dfs(int o, int p) {
  siz[o] = 1;
  deep[o] = deep[p] + 1;
  fa[o] = p;
  for (int i = first[o]; i != -1; i = nxt[i])
    if (to[i] != p) {
      dfs(to[i], o);
      siz[o] += siz[to[i]];
      if (siz[to[i]] > siz[heavy[o]]) heavy[o] = to[i];
    }
}
void dfs1(int o, int p) {
  pos[o] = ++x2;
  if (heavy[o] > 0) {
    top[heavy[o]] = top[o];
    dfs1(heavy[o], o);
    for (int i = first[o]; i != -1; i = nxt[i])
      if ((to[i] != p) && (to[i] != heavy[o])) {
        top[to[i]] = to[i];
        dfs1(to[i], o);
      }
  }
}
void put(int o, int p, int q, int r, int s) {
  if ((o == q) && (p == q)) {
    seg[r] = s;
    return;
  }
  int mid = (o + p) / 2;
  if (q <= mid) {
    put(o, mid, q, r * 2, s);
    seg[r] = min(seg[r * 2 + 1], seg[r * 2]);
  } else {
    put(mid + 1, p, q, r * 2 + 1, s);
    seg[r] = min(seg[r * 2], seg[r * 2 + 1]);
  }
}
int get(int o, int p, int q, int r, int s) {
  if ((o == q) && (p == r)) return seg[s];
  int mid = (o + p) / 2;
  if (r <= mid)
    return get(o, mid, q, r, s * 2);
  else if (q > mid)
    return get(mid + 1, p, q, r, s * 2 + 1);
  else
    return min(get(o, mid, q, mid, s * 2),
               get(mid + 1, p, mid + 1, r, s * 2 + 1));
}
int gettree(int o, int p) {
  int yu = INF;
  while (top[o] != top[p]) {
    if (deep[top[o]] < deep[top[p]]) {
      int t = o;
      o = p;
      p = t;
    }
    yu = min(yu, get(1, sum, pos[top[o]], pos[o], 1));
    o = fa[top[o]];
  }
  if (deep[o] > deep[p]) {
    int t = o;
    o = p;
    p = t;
  }
  yu = min(yu, get(1, sum, pos[o], pos[p], 1));
  if (o > n) yu = min(yu, ss[fa[o]]);
  return yu;
}
int main() {
  memset(first1, -1, sizeof(first1));
  memset(first, -1, sizeof(first));
  scanf("%d%d%d", &n, &m, &q);
  sum = n;
  for (int i = 1; i <= n; i++) scanf("%d", &ss[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Build(x, y);
    Build(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  deep[0] = 0;
  dfs(1, 0);
  top[1] = 1;
  dfs1(1, 0);
  for (int i = 1; i <= n; i++)
    if (fa[i] > 0) {
      fang[fa[i]].insert(ss[i]);
      if (!cishu[fa[i]].count(ss[i])) cishu[fa[i]][ss[i]] = 0;
      cishu[fa[i]][ss[i]]++;
    }
  for (int i = n + 1; i <= sum; i++) ss[i] = *fang[i].begin();
  for (int i = 0; i <= 1000000; i++) seg[i] = INF + 1;
  for (int i = 1; i <= sum; i++) put(1, sum, pos[i], 1, ss[i]);
  for (int i = 1; i <= q; i++) {
    int x, y;
    getchar();
    scanf("%c%d%d", &ch, &x, &y);
    if (ch == 'C') {
      if (fa[x] > 0) {
        cishu[fa[x]][ss[x]]--;
        if (cishu[fa[x]][ss[x]] == 0) fang[fa[x]].erase(ss[x]);
        if (!cishu[fa[x]].count(y)) cishu[fa[x]][y] = 0;
        cishu[fa[x]][y]++;
        fang[fa[x]].insert(y);
        put(1, sum, pos[fa[x]], 1, (*fang[fa[x]].begin()));
      }
      put(1, sum, pos[x], 1, y);
      ss[x] = y;
    } else
      cout << gettree(x, y) << endl;
  }
  return 0;
}