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>
namespace ztd {
using namespace std;
const int inf = 0x3f3f3f3f;
template <typename T>
inline T read(T& t) {
  t = 0;
  short f = 1;
  char ch = getchar();
  double d = 0.1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t *= f;
  return t;
}
}  // namespace ztd
using namespace ztd;
const int maxn = 2e5 + 7;
const int maxm = 4e5 + 7;
int n, m, qq, a[maxn];
struct edge {
  int y[maxm], gg[maxm], last[maxn], ecnt;
  inline void addedge(int x, int yy) {
    y[++ecnt] = yy, gg[ecnt] = last[x];
    last[x] = ecnt;
  }
} E, G;
int dfx[maxn], low[maxn], dfxcnt, st[maxn], top, gtot;
void Tarjan(int x) {
  dfx[x] = low[x] = ++dfxcnt;
  st[top++] = x;
  for (int i = E.last[x], y = E.y[i]; i; i = E.gg[i], y = E.y[i]) {
    if (!dfx[y]) {
      Tarjan(y);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfx[x]) {
        ++gtot;
        do {
          G.addedge(st[--top], gtot);
          G.addedge(gtot, st[top]);
        } while (st[top] ^ y);
        G.addedge(gtot, x);
        G.addedge(x, gtot);
      }
    } else
      low[x] = min(low[x], dfx[y]);
  }
}
int dad[maxn], dfn[maxn], dep[maxn], siz[maxn], wson[maxn], pcnt, rev[maxn],
    peak[maxn];
void dfs1(int x, int fa) {
  dep[x] = dep[fa] + 1, siz[x] = 1, dad[x] = fa;
  for (int i = G.last[x], y = G.y[i]; i; i = G.gg[i], y = G.y[i])
    if (y ^ fa) {
      dfs1(y, x);
      siz[x] += siz[y];
      if (siz[wson[x]] < siz[y]) wson[x] = y;
    }
}
void dfs2(int x, int tp) {
  dfn[x] = ++pcnt;
  rev[pcnt] = x;
  peak[x] = tp;
  if (wson[x]) dfs2(wson[x], tp);
  for (int i = G.last[x], y = G.y[i]; i; i = G.gg[i], y = G.y[i]) {
    if ((y ^ dad[x]) && (y ^ wson[x])) dfs2(y, y);
  }
}
class SegmentTree {
 public:
  int tree[maxn << 2], cnt;
  void build(int l, int r, int now) {
    if (l == r) {
      tree[now] = a[rev[l]];
    } else {
      int mid = (l + r) >> 1;
      build(l, mid, now << 1);
      build(mid + 1, r, (now << 1) + 1);
      tree[now] = min(tree[now << 1], tree[(now << 1) + 1]);
    }
  }
  void update(int l, int r, int now, int x, int late) {
    if (l == r)
      tree[now] = late;
    else {
      int mid = (l + r) >> 1;
      if (x <= mid)
        update(l, mid, (now << 1), x, late);
      else
        update(mid + 1, r, (now << 1) + 1, x, late);
      tree[now] = min(tree[now << 1], tree[(now << 1) + 1]);
    }
  }
  int ask(int l, int r, int now, int ql, int qr) {
    int ret = inf;
    if (ql <= l && qr >= r) {
      ret = tree[now];
    } else {
      int mid = (l + r) >> 1;
      if (ql <= mid) ret = min(ret, ask(l, mid, (now << 1), ql, qr));
      if (qr > mid) ret = min(ret, ask(mid + 1, r, (now << 1) + 1, ql, qr));
    }
    return ret;
  }
} T;
multiset<int> s[maxn];
int Query(int x, int y) {
  int ret = inf;
  while (peak[x] != peak[y]) {
    if (dep[peak[x]] > dep[peak[y]]) swap(x, y);
    ret = min(ret, T.ask(1, gtot, 1, dfn[peak[y]], dfn[y]));
    y = dad[peak[y]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  ret = min(ret, T.ask(1, gtot, 1, dfn[x], dfn[y]));
  return ((x > n) ? (min(ret, a[dad[x]])) : ret);
}
signed main() {
  gtot = read(n);
  read(m);
  read(qq);
  for (int i = 1; i <= n; ++i) read(a[i]);
  int xx, yy, ans;
  char opt;
  for (int i = 1; i <= m; ++i) {
    read(xx);
    read(yy);
    E.addedge(xx, yy);
    E.addedge(yy, xx);
  }
  Tarjan(1);
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i)
    if (dad[i]) s[dad[i]].insert(a[i]);
  for (int i = n + 1; i <= gtot; ++i) a[i] = *s[i].begin();
  T.build(1, gtot, 1);
  while (qq--) {
    cin >> opt;
    read(xx);
    read(yy);
    if (opt == 'C') {
      T.update(1, gtot, 1, dfn[xx], yy);
      if (dad[xx]) {
        int fa = dad[xx];
        s[fa].erase(s[fa].lower_bound(a[xx]));
        s[fa].insert(yy);
        if (a[fa] != *s[fa].begin()) {
          a[fa] = *s[fa].begin();
          T.update(1, gtot, 1, dfn[fa], a[fa]);
        }
      }
      a[xx] = yy;
    } else {
      cout << Query(xx, yy) << '\n';
    }
  }
  return 0;
}