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 N = 4e5 + 7, M = 20;
char g;
struct tree {
  int a, b, c, t;
} tr[N << 1];
struct edge {
  int a, b;
} ed[N], edg[N];
set<int> hig[N];
map<int, int> s[N];
int n, m, k, siz, res, tota, totb, lint, themin, w[N], fa[N], fb[N], st[N],
    dep[N], pos[N], ret[N], ffa[N], fson[N], low[N], dfn[N], dfsn[N], e[N][M];
inline int read() {
  int num = 0;
  g = getchar();
  while (g < 48 || 57 < g) g = getchar();
  while (47 < g && g < 58)
    num = (num << 1) + (num << 3) + g - 48, g = getchar();
  return num;
}
inline int Min(int a, int b) {
  if (a < b) return a;
  return b;
}
inline int Max(int a, int b) {
  if (a > b) return a;
  return b;
}
inline void addedgea(int a, int b) {
  tota++, ed[tota].a = b, ed[tota].b = fa[a], fa[a] = tota;
}
inline void addedgeb(int a, int b) {
  totb++, edg[totb].a = b, edg[totb].b = fb[a], fb[a] = totb;
}
inline void tarjan(int u) {
  dfn[u] = low[u] = ++siz, st[++st[0]] = u;
  for (int i = fa[u]; i > 0; i = ed[i].b) {
    int x = ed[i].a;
    if (dfn[x])
      low[u] = Min(low[u], dfn[x]);
    else {
      tarjan(x), low[u] = Min(low[u], low[x]);
      if (low[x] >= dfn[u]) {
        res++, addedgeb(res, u), addedgeb(u, res);
        while (st[st[0] + 1] != x)
          addedgeb(res, st[st[0]]), addedgeb(st[st[0]--], res);
      }
    }
  }
}
inline void find(int u) {
  int z = 1;
  ret[u] = 1;
  while ((1 << z) < dep[u]) e[u][z] = e[e[u][z - 1]][z - 1], z++;
  for (int i = fb[u]; i > 0; i = edg[i].b) {
    int x = edg[i].a;
    if (fa[u] != x) {
      fa[x] = u, dep[x] = dep[u] + 1, e[x][0] = u, find(x);
      if (u > n) {
        if (!s[u][w[x]]) hig[u].insert(w[x]);
        s[u][w[x]]++;
      }
      if (ret[x] > ret[fson[u]]) fson[u] = x;
      ret[u] += ret[x];
    }
  }
}
inline void search(int u) {
  if (!ffa[u]) ffa[u] = u;
  dfsn[u] = ++lint;
  if (fson[u])
    ffa[fson[u]] = ffa[u], search(fson[u]);
  else
    fson[u] = u;
  for (int i = fb[u]; i > 0; i = edg[i].b) {
    int x = edg[i].a;
    if (fa[u] != x && fson[u] != x) search(x);
  }
}
inline void build(int a, int b, int c) {
  tr[c].a = a, tr[c].b = b, tr[c].c = (a + b) >> 1;
  if (a == b) {
    pos[a] = c;
    return;
  }
  build(tr[c].a, tr[c].c, c << 1), build(tr[c].c + 1, tr[c].b, c << 1 | 1);
}
inline void inser(int u, int x) {
  tr[u].t = x, u = u >> 1;
  while (u > 0) tr[u].t = Min(tr[u << 1].t, tr[u << 1 | 1].t), u = u >> 1;
}
inline int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int z = dep[a] - dep[b];
  for (int x = 18; x >= 0; x--)
    if (z & (1 << x)) a = e[a][x];
  if (a == b) return a;
  for (int x = 18; x >= 0; x--)
    if (e[a][x] != e[b][x]) a = e[a][x], b = e[b][x];
  return e[a][0];
}
inline void searchans(int a, int b, int c) {
  if (tr[c].a == a && tr[c].b == b) {
    themin = Min(tr[c].t, themin);
    return;
  }
  if (a <= tr[c].c) searchans(a, Min(b, tr[c].c), c << 1);
  if (tr[c].c < b) searchans(Max(tr[c].c + 1, a), b, c << 1 | 1);
}
inline void write(int u) {
  if (u > 9) write(u / 10);
  putchar(u % 10 + '0');
}
int main() {
  n = read(), m = read(), k = read(), res = n, build(1, n << 1, 1);
  int a, b, c;
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= m; i++)
    a = read(), b = read(), addedgea(a, b), addedgea(b, a);
  tarjan(1), fa[1] = 0, dep[1] = 1, find(1), search(1);
  for (int i = 1; i <= n; i++) inser(pos[dfsn[i]], w[i]);
  for (int i = n + 1; i <= res; i++) inser(pos[dfsn[i]], *hig[i].begin());
  for (int i = 1; i <= k; i++) {
    g = getchar();
    while (g != 'A' && g != 'C') g = getchar();
    if (g == 'C') {
      a = read(), b = read();
      if (fa[a]) {
        s[fa[a]][w[a]]--;
        if (!s[fa[a]][w[a]]) hig[fa[a]].erase(w[a]);
        w[a] = b;
        if (!s[fa[a]][w[a]]) hig[fa[a]].insert(w[a]);
        s[fa[a]][w[a]]++;
        inser(pos[dfsn[fa[a]]], *hig[fa[a]].begin());
      }
      w[a] = b, inser(pos[dfsn[a]], w[a]);
    } else {
      a = read(), b = read(), c = lca(a, b), themin = 1e9 + 7;
      while (ffa[a] != ffa[c])
        searchans(dfsn[ffa[a]], dfsn[a], 1), a = fa[ffa[a]];
      while (ffa[b] != ffa[c])
        searchans(dfsn[ffa[b]], dfsn[b], 1), b = fa[ffa[b]];
      searchans(dfsn[c], dfsn[a], 1), searchans(dfsn[c], dfsn[b], 1);
      if (c > n) themin = Min(themin, w[fa[c]]);
      write(themin), putchar('\n');
    }
  }
  return 0;
}