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;
int P1 = 1000000, P2 = 0;
char buf[1000005], wb[1000005];
int gc() {
  if (P1 >= 1000000) fread(buf, 1, 1000000, stdin), P1 = 0;
  return buf[P1++];
}
long long getint() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    ret = (ret << 3) + (ret << 1) + c - '0';
    c = getchar();
  }
  return ret * flag;
}
void pc(char x) {
  if (P2 >= 1000000) fwrite(wb, 1, 1000000, stdout), P2 = 0;
  wb[P2++] = x;
}
void wrt(long long x) {
  if (x < 0) pc('-'), x = -x;
  int c[24] = {0};
  if (!x) return pc('0'), void();
  while (x) c[++c[0]] = x % 10, x /= 10;
  while (c[0]) pc(c[c[0]--] + '0');
}
int n, m, Q, tot;
struct edge {
  int ne, v;
} e[800005];
int head[400005], cnt = 1;
void add(int u, int v) {
  ++cnt;
  e[cnt].v = v;
  e[cnt].ne = head[u];
  head[u] = cnt;
}
int dfn[400005], low[400005], sign, tg[400005], w[400005];
vector<int> vec[400005], G[400005];
map<int, int> vis[400005];
multiset<int> p[400005];
stack<int> s;
void tarjan(int x) {
  dfn[x] = low[x] = ++sign, s.push(x);
  int sz = vec[x].size();
  for (int i = 0; i < sz; i++) {
    int y = vec[x][i];
    if (!dfn[y]) {
      tarjan(y), low[x] = min(low[x], low[y]);
      if (low[y] == dfn[x]) {
        ++tot;
        do {
          add(tot, s.top()), add(s.top(), tot);
          p[tot].insert(w[s.top()]);
          G[tot].push_back(s.top());
          if (s.top() == y) {
            s.pop();
            break;
          }
          s.pop();
        } while (1);
        add(x, tot), add(tot, x), w[tot] = *p[tot].begin();
        tg[tot] = (G[tot].size() == 1) && (vis[x][G[tot][0]] == 1);
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
int sz[400005], son[400005], dep[400005], fa[400005];
void dfs1(int x, int prt) {
  sz[x] = 1, fa[x] = prt, dep[x] = dep[prt] + 1;
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt) continue;
    dfs1(y, x), sz[x] += sz[y];
    if (sz[son[x]] < sz[y]) son[x] = y;
  }
}
int tp[400005], rd[400005], cd[400005], ind[400005];
void dfs2(int x, int prt, int top) {
  ind[rd[x] = ++sign] = x, tp[x] = top;
  if (son[x]) dfs2(son[x], x, top);
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt || y == son[x]) continue;
    dfs2(y, x, y);
  }
  cd[x] = sign;
}
struct Segment_tree {
  struct node {
    int l, r;
    int val;
  } v[1600005];
  void build(int rt, int l, int r) {
    v[rt].l = l, v[rt].r = r;
    if (l == r) {
      v[rt].val = w[ind[l]];
      return;
    }
    int mid = (l + r) >> 1;
    build(rt << 1, l, mid);
    build(rt << 1 | 1, mid + 1, r);
    v[rt].val = min(v[rt << 1].val, v[rt << 1 | 1].val);
  }
  int ask(int rt, int l, int r) {
    if (l <= v[rt].l && v[rt].r <= r) return v[rt].val;
    int ret = 0x3f3f3f3f, mid = v[rt << 1].r;
    if (l <= mid) ret = min(ret, ask(rt << 1, l, r));
    if (mid < r) ret = min(ret, ask(rt << 1 | 1, l, r));
    return ret;
  }
  void update(int rt, int p) {
    if (v[rt].l == v[rt].r) {
      v[rt].val = w[ind[v[rt].l]];
      return;
    }
    int mid = v[rt << 1].r;
    update(p <= mid ? rt << 1 : rt << 1 | 1, p);
    v[rt].val = min(v[rt << 1].val, v[rt << 1 | 1].val);
  }
} S;
int ask(int x, int y) {
  int ret = 0x3f3f3f3f;
  while (tp[x] ^ tp[y]) {
    if (dep[tp[x]] < dep[tp[y]]) swap(x, y);
    ret = min(ret, S.ask(1, rd[tp[x]], rd[x]));
    x = fa[tp[x]];
  }
  if (rd[x] > rd[y]) swap(x, y);
  ret = min(ret, S.ask(1, rd[x], rd[y]));
  return x <= n ? ret : min(ret, w[fa[x]]);
}
int main() {
  tot = n = getint();
  m = getint();
  Q = getint();
  for (int i = 1; i <= n; i++) w[i] = getint();
  for (int i = 1; i <= m; i++) {
    int u = getint(), v = getint();
    ++vis[u][v], ++vis[v][u];
    vec[u].push_back(v), vec[v].push_back(u);
  }
  tarjan(1), sign = 0;
  dfs1(1, 0), dfs2(1, 0, 1);
  S.build(1, 1, sign);
  for (int i = 1; i <= Q; i++) {
    char c = getchar();
    while (c != 'C' && c != 'A') c = getchar();
    if (c == 'C') {
      int x = getint(), val = getint();
      if (fa[x]) {
        p[fa[x]].erase(p[fa[x]].find(w[x]));
        p[fa[x]].insert(val);
        w[fa[x]] = *p[fa[x]].begin();
        S.update(1, rd[fa[x]]);
      }
      w[x] = val;
      S.update(1, rd[x]);
    }
    if (c == 'A') {
      int x = getint(), y = getint();
      wrt(ask(x, y)), pc('\n');
    }
  }
  fwrite(wb, 1, P2, stdout);
  return 0;
}