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 superset {
  multiset<int> m;
  void insert(int x) { m.insert(x); }
  void erase(int x) { m.erase(m.find(x)); }
  int query() { return *m.begin(); }
};
int n, m;
int val[65536 * 4];
superset cl[65536 * 4];
vector<int> g[65536 * 4];
vector<int> lis[65536 * 4];
int dfn[65536 * 4];
int DFN;
int low[65536 * 4];
int st[65536 * 4], stsiz;
int tot;
vector<int> v[65536 * 4];
void addedge(int x, int y) {
  v[x].push_back(y);
  v[y].push_back(x);
}
void tarjan(int x, int p) {
  st[++stsiz] = x;
  dfn[x] = low[x] = ++DFN;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (y == p) continue;
    if (!dfn[y]) {
      tarjan(y, x);
      if (low[y] >= dfn[x]) {
        ++tot;
        while (st[stsiz] != y) lis[tot].push_back(st[stsiz--]);
        stsiz--;
        lis[tot].push_back(y);
        lis[tot].push_back(x);
        for (int j = 0; j < lis[tot].size(); j++) addedge(lis[tot][j], tot);
      }
      low[x] = min(low[x], low[y]);
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
struct segmenttree {
  int tree[65536 * 4 * 2 + 10];
  void up(int id) { tree[id] = min(tree[id << 1], tree[id << 1 | 1]); }
  void update(int x, int y) {
    x = x + 65536 * 4 - 1;
    tree[x] = y;
    x = x / 2;
    while (x) up(x), x = x / 2;
  }
  int query(int a, int b, int l, int r, int id) {
    if (l >= a and r <= b) return tree[id];
    if (b <= (l + r) / 2)
      return query(a, b, l, (l + r) / 2, id << 1);
    else if (a > (l + r) / 2)
      return query(a, b, (l + r) / 2 + 1, r, id << 1 | 1);
    else
      return min(query(a, b, l, (l + r) / 2, id << 1),
                 query(a, b, (l + r) / 2 + 1, r, id << 1 | 1));
  }
  int query(int a, int b) { return query(a, b, 1, 65536 * 4, 1); }
} trcyx;
int pa[65536 * 4];
int son[65536 * 4];
int siz[65536 * 4];
int lead[65536 * 4];
int len[65536 * 4];
int dep[65536 * 4];
void dfs1(int x, int p) {
  siz[x] = 1;
  dep[x] = dep[p] + 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] == p) continue;
    dfs1(v[x][i], x);
    siz[x] += siz[v[x][i]];
    if (siz[v[x][i]] > siz[son[x]]) son[x] = v[x][i];
  }
}
void dfs2(int x, int p, int leader) {
  dfn[x] = ++DFN;
  pa[x] = p;
  if (!leader) leader = x;
  lead[x] = leader, len[leader]++;
  if (son[x]) dfs2(son[x], x, leader);
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i] != son[x] and v[x][i] != p) dfs2(v[x][i], x, 0);
  if (lis[x].size()) {
    for (int i = 0; i < lis[x].size(); i++)
      if (lis[x][i] != pa[x]) cl[x].insert(val[lis[x][i]]);
    val[x] = cl[x].query();
  }
  trcyx.update(dfn[x], val[x]);
}
void build() {
  tot = n;
  tarjan(1, 0);
  dfs1(1, 0);
  memset(dfn, 0, sizeof(dfn));
  DFN = 0;
  dfs2(1, 0, 0);
}
int solve(int x, int y) {
  int ans = 1e9;
  while (lead[x] != lead[y]) {
    if (dep[lead[x]] < dep[lead[y]]) swap(x, y);
    ans = min(ans, trcyx.query(dfn[lead[x]], dfn[x]));
    x = pa[lead[x]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  ans = min(ans, trcyx.query(dfn[x], dfn[y]));
  if (lis[x].size()) ans = min(ans, val[pa[x]]);
  return ans;
}
void change(int x, int y) {
  if (pa[x]) {
    cl[pa[x]].erase(val[x]);
    cl[pa[x]].insert(y);
    val[pa[x]] = cl[pa[x]].query();
    trcyx.update(dfn[pa[x]], val[pa[x]]);
  }
  val[x] = y;
  trcyx.update(dfn[x], y);
}
int main() {
  int T;
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  build();
  while (T--) {
    char ctrl[10];
    scanf("%s", ctrl);
    int x, y;
    scanf("%d%d", &x, &y);
    if (ctrl[0] == 'A')
      printf("%d\n", solve(x, y));
    else
      change(x, y);
  }
  return 0;
}