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;
inline int rd() {
  int rx = 0, fx = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') fx = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) {
    rx = rx * 10 + c - 48;
    c = getchar();
  }
  return rx * fx;
}
inline int rdc() {
  char c = getchar();
  while (c != 'A' && c != 'C') c = getchar();
  return c == 'A';
}
const int N = 4e5 + 50, Log = 20, inf = 1e9 + 50;
int n, m, Q, tot = 0;
int W[N];
struct Link {
  int cnt;
  int he[N];
  struct Edge {
    int v, nxt;
  } e[N];
  inline void add(int uu, int vv) {
    cnt++;
    e[cnt].v = vv;
    e[cnt].nxt = he[uu];
    he[uu] = cnt;
    cnt++;
    e[cnt].v = uu;
    e[cnt].nxt = he[vv];
    he[vv] = cnt;
  }
} G, T;
struct Segment_tree {
  int val[N << 2];
  inline void mup(int rt) {
    val[rt] = min(val[(rt << 1)], val[((rt << 1) | 1)]);
  }
  inline void change(int rt, int l, int r, int x, int nv) {
    if (l == r) {
      val[rt] = nv;
      return;
    }
    int mid = (l + r) >> 1;
    if (mid >= x)
      change((rt << 1), l, mid, x, nv);
    else
      change(((rt << 1) | 1), mid + 1, r, x, nv);
    mup(rt);
  }
  inline int query(int rt, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
      return val[rt];
    }
    int mid = (l + r) >> 1, ras = inf;
    if (mid >= x) ras = min(ras, query((rt << 1), l, mid, x, y));
    if (mid < y) ras = min(ras, query(((rt << 1) | 1), mid + 1, r, x, y));
    return ras;
  }
} s;
struct RBT {
  int cur;
  int fa[N], prf[N], det[N], siz[N], ms[N], dfn[N];
  multiset<int> st[N];
  inline void dfs(int x, int nf) {
    int i, vv;
    siz[x] = 1;
    det[x] = det[nf] + 1;
    fa[x] = nf;
    for (i = T.he[x]; i; i = T.e[i].nxt) {
      vv = T.e[i].v;
      if (vv == nf) continue;
      dfs(vv, x);
      siz[x] += siz[vv];
      if (ms[x] == 0 || siz[vv] > siz[ms[x]]) ms[x] = vv;
    }
  }
  inline void dfs2(int x, int bf) {
    int i, vv;
    prf[x] = bf;
    dfn[x] = ++cur;
    if (ms[x]) dfs2(ms[x], bf);
    for (i = T.he[x]; i; i = T.e[i].nxt) {
      vv = T.e[i].v;
      if (vv == fa[x] || vv == ms[x]) continue;
      dfs2(vv, vv);
    }
  }
  inline void build() {
    int i;
    for (i = 1; i <= n; i++) {
      if (fa[i]) st[fa[i]].insert(W[i]);
    }
    for (i = 1; i <= n; i++) s.change(1, 1, tot, dfn[i], W[i]);
    for (i = n + 1; i <= tot; i++) s.change(1, 1, tot, dfn[i], *st[i].begin());
  }
  inline int solve(int x, int y, int &lca) {
    int ras = inf;
    while (prf[x] != prf[y]) {
      if (det[prf[x]] < det[prf[y]]) swap(x, y);
      ras = min(ras, s.query(1, 1, tot, dfn[prf[x]], dfn[x]));
      x = fa[prf[x]];
    }
    if (x == y) {
      ras = min(ras, s.query(1, 1, tot, dfn[x], dfn[x]));
      lca = x;
      return ras;
    }
    if (det[x] > det[y]) swap(x, y);
    ras = min(ras, s.query(1, 1, tot, dfn[x], dfn[y]));
    lca = x;
    return ras;
  }
  inline void change(int x, int nv) {
    if (fa[x]) {
      st[fa[x]].erase(st[fa[x]].find(W[x]));
      st[fa[x]].insert(nv);
      s.change(1, 1, tot, dfn[fa[x]], *st[fa[x]].begin());
    }
    W[x] = nv;
    s.change(1, 1, tot, dfn[x], W[x]);
  }
  inline int query(int x, int y) {
    int lca, ras;
    ras = solve(x, y, lca);
    if (lca > n && fa[lca]) ras = min(ras, W[fa[lca]]);
    return ras;
  }
} rbt;
int cur = 0, top = 0;
int dfn[N], pre[N], sta[N];
inline void tarjan(int x) {
  int i, vv;
  dfn[x] = pre[x] = ++cur;
  sta[++top] = x;
  for (i = G.he[x]; i; i = G.e[i].nxt) {
    vv = G.e[i].v;
    if (!dfn[vv]) {
      tarjan(vv);
      pre[x] = min(pre[x], pre[vv]);
      if (pre[vv] >= dfn[x]) {
        tot++;
        while (sta[top + 1] != vv) {
          T.add(sta[top], tot);
          top--;
        }
        T.add(x, tot);
      }
    } else
      pre[x] = min(pre[x], dfn[vv]);
  }
}
int main() {
  int i, uu, vv, op, x, y;
  n = rd();
  m = rd();
  Q = rd();
  for (i = 1; i <= n; i++) W[i] = rd();
  for (i = 1; i <= m; i++) {
    uu = rd();
    vv = rd();
    G.add(uu, vv);
  }
  tot = n;
  tarjan(1);
  rbt.dfs(1, 0);
  rbt.dfs2(1, 0);
  rbt.build();
  while (Q--) {
    op = rdc();
    x = rd();
    y = rd();
    if (op == 0)
      rbt.change(x, y);
    else
      printf("%d\n", rbt.query(x, y));
  }
  return 0;
}