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;
vector<int> graph[100005];
int low[100005], dfn[100005], piv;
vector<int> bcc[100005];
int cutp[100005], col, cutf[200005], cloc[200005];
void dfs(int x, int p) {
  dfn[x] = low[x] = ++piv;
  for (auto &i : graph[x]) {
    if (i == p) continue;
    if (dfn[i]) {
      low[x] = min(low[x], dfn[i]);
    } else {
      dfs(i, x);
      low[x] = min(low[x], low[i]);
    }
  }
}
void color(int x, int c) {
  if (c > 0) bcc[x].push_back(c);
  for (auto &i : graph[x]) {
    if (bcc[i].size()) continue;
    if (low[i] >= dfn[x]) {
      col++;
      bcc[x].push_back(col);
      cutf[col] = x;
      color(i, col);
    } else {
      color(i, c);
    }
  }
}
int a[100005];
int n, m, q;
vector<int> tree[200005];
multiset<int> ms[200005];
int dep[200005], par[18][200005];
int tpiv, tdfn[200005], size[200005];
int comp[200005], chead[200005], cnum;
void tdfs(int x, int p) {
  par[0][x] = p;
  for (int i = 1; i <= 17; i++) {
    par[i][x] = par[i - 1][par[i - 1][x]];
  }
  size[x] = 1;
  for (auto &i : tree[x]) {
    if (i == p) continue;
    dep[i] = dep[x] + 1;
    tdfs(i, x);
    size[x] += size[i];
  }
}
void hld(int x, int p) {
  tdfn[x] = ++tpiv;
  int cmax = -1, son = -1;
  for (auto &i : tree[x]) {
    if (i == p) continue;
    if (size[i] > cmax) {
      cmax = size[i];
      son = i;
    }
  }
  comp[x] = cnum;
  if (son != -1) hld(son, x);
  for (auto &i : tree[x]) {
    if (i != son && i != p) {
      cnum++;
      chead[cnum] = i;
      hld(i, x);
    }
  }
}
struct rmq {
  int tree[530000], lim;
  void init(int n) {
    for (lim = 1; lim <= n; lim <<= 1)
      ;
    fill(tree, tree + 2 * lim, 1e9);
  }
  void upd(int x, int v) {
    x += lim;
    tree[x] = v;
    while (x > 1) {
      x >>= 1;
      tree[x] = min(tree[2 * x], tree[2 * x + 1]);
    }
  }
  int query(int s, int e) {
    s += lim;
    e += lim;
    int ret = 1e9;
    while (s < e) {
      if (s % 2 == 1) ret = min(ret, tree[s++]);
      if (e % 2 == 0) ret = min(ret, tree[e--]);
      s >>= 1;
      e >>= 1;
    }
    if (s == e) ret = min(ret, tree[s]);
    return ret;
  }
} rmq;
int lca(int s, int e) {
  if (dep[s] < dep[e]) swap(s, e);
  int dx = dep[s] - dep[e];
  for (int i = 0; i <= 17; i++) {
    if ((dx >> i) & 1) s = par[i][s];
  }
  for (int i = 17; i >= 0; i--) {
    if (par[i][s] != par[i][e]) {
      s = par[i][s];
      e = par[i][e];
    }
  }
  if (s != e) return par[0][s];
  return s;
}
int query(int s, int e) {
  int ret = 1e9;
  while (comp[s] != comp[e]) {
    ret = min(ret, rmq.query(tdfn[chead[comp[s]]], tdfn[s]));
    s = par[0][chead[comp[s]]];
  }
  ret = min(ret, rmq.query(tdfn[e], tdfn[s]));
  return ret;
}
void update(int x) { rmq.upd(tdfn[x], *ms[x].begin()); }
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    int s, e;
    scanf("%d %d", &s, &e);
    graph[s].push_back(e);
    graph[e].push_back(s);
  }
  dfs(1, 0);
  color(1, 0);
  for (int i = 1; i <= n; i++) {
    if (bcc[i].size() > 1) {
      cutp[i] = ++col;
      cloc[col] = i;
      for (auto &j : bcc[i]) {
        tree[j].push_back(col);
        tree[col].push_back(j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!cutp[i]) {
      ms[bcc[i][0]].insert(a[i]);
    } else {
      ms[bcc[i][0]].insert(a[i]);
      ms[cutp[i]].insert(a[i]);
    }
  }
  tdfs(1, 0);
  chead[1] = 1;
  cnum = 1;
  hld(1, 0);
  rmq.init(col);
  for (int i = 1; i <= col; i++) {
    update(i);
  }
  while (q--) {
    char buf[5];
    int s, e;
    scanf("%s %d %d", buf, &s, &e);
    if (*buf == 'A') {
      if (s == e) {
        printf("%d\n", a[s]);
        continue;
      }
      if (cutp[s])
        s = cutp[s];
      else
        s = bcc[s][0];
      if (cutp[e])
        e = cutp[e];
      else
        e = bcc[e][0];
      int ret = 1e9, l = lca(s, e);
      if (cutf[l])
        ret = a[cutf[l]];
      else if (cloc[l])
        ret = min(ret, a[cloc[l]]);
      ret = min(ret, query(s, l));
      ret = min(ret, query(e, l));
      printf("%d\n", ret);
    } else {
      if (!cutp[s]) {
        ms[bcc[s][0]].erase(ms[bcc[s][0]].find(a[s]));
        ms[bcc[s][0]].insert(e);
        update(bcc[s][0]);
      } else {
        ms[bcc[s][0]].erase(ms[bcc[s][0]].find(a[s]));
        ms[bcc[s][0]].insert(e);
        ms[cutp[s]].erase(ms[cutp[s]].find(a[s]));
        ms[cutp[s]].insert(e);
        update(bcc[s][0]);
        update(cutp[s]);
      }
      a[s] = e;
    }
  }
}