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>
const int INF = 0x3f3f3f3f;
const int N = 400005;
const int E = 800005;
std::stack<int> stack;
std::multiset<int> set[N];
struct Graph {
  struct edge {
    int y, next;
  } e[E];
  int ls[N], edCnt;
  void add_edge(int x, int y) {
    e[++edCnt] = (edge){y, ls[x]};
    ls[x] = edCnt;
    e[++edCnt] = (edge){x, ls[y]};
    ls[y] = edCnt;
  }
} G, T;
int min[N << 2], tot, n;
int dfn[N], low[N], w[N], dep[N];
int size[N], pos[N], bl[N], fa[N];
bool vis[N];
int read() {
  int x = 0, v = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; v = (ch == '-') ? (-1) : (v), ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - '0', ch = getchar())
    ;
  return x * v;
}
void tarjan(int now, int from) {
  dfn[now] = low[now] = ++dfn[0];
  vis[now] = 1;
  for (int i = G.ls[now]; i; i = G.e[i].next) {
    if (i == (from ^ 1)) continue;
    if (!dfn[G.e[i].y]) {
      stack.push(i);
      tarjan(G.e[i].y, i);
      low[now] = std::min(low[now], low[G.e[i].y]);
      if (dfn[now] <= low[G.e[i].y]) {
        int y = 0;
        w[++tot] = INF;
        while (y != i) {
          y = stack.top();
          stack.pop();
          T.add_edge(G.e[y].y, tot);
        }
        T.add_edge(now, tot);
      }
    } else if (vis[G.e[i].y])
      low[now] = std::min(low[now], dfn[G.e[i].y]);
  }
  vis[now] = 0;
}
void dfs1(int now) {
  size[now] = 1;
  for (int i = T.ls[now]; i; i = T.e[i].next) {
    if (T.e[i].y == fa[now]) continue;
    fa[T.e[i].y] = now;
    dep[T.e[i].y] = dep[now] + 1;
    dfs1(T.e[i].y);
    size[now] += size[T.e[i].y];
  }
}
void dfs2(int now, int up) {
  int mx = 0;
  pos[now] = ++pos[0];
  bl[now] = up;
  for (int i = T.ls[now]; i; i = T.e[i].next) {
    if (T.e[i].y != fa[now] && size[T.e[i].y] > size[mx]) mx = T.e[i].y;
  }
  if (!mx) return;
  dfs2(mx, up);
  for (int i = T.ls[now]; i; i = T.e[i].next) {
    if (T.e[i].y != fa[now] && T.e[i].y != mx) dfs2(T.e[i].y, T.e[i].y);
  }
}
void modify(int now, int tl, int tr, int x, int v) {
  if (tl == tr) return (void)(min[now] = v);
  int mid = (tl + tr) >> 1;
  if (x <= mid)
    modify(now << 1, tl, mid, x, v);
  else
    modify(now << 1 | 1, mid + 1, tr, x, v);
  min[now] = std::min(min[now << 1], min[now << 1 | 1]);
}
int query(int now, int tl, int tr, int l, int r) {
  if (tl == l && tr == r) return min[now];
  int mid = (tl + tr) >> 1;
  if (r <= mid) return query(now << 1, tl, mid, l, r);
  if (l > mid) return query(now << 1 | 1, mid + 1, tr, l, r);
  int qx = query(now << 1, tl, mid, l, mid);
  int qy = query(now << 1 | 1, mid + 1, tr, mid + 1, r);
  return std::min(qx, qy);
}
void solve(int x, int y) {
  int ans = INF;
  while (bl[x] != bl[y]) {
    if (dep[bl[x]] < dep[bl[y]]) std::swap(x, y);
    int ret = query(1, 1, pos[0], pos[bl[x]], pos[x]);
    ans = std::min(ret, ans);
    x = fa[bl[x]];
  }
  if (pos[x] > pos[y]) std::swap(x, y);
  ans = std::min(ans, query(1, 1, pos[0], pos[x], pos[y]));
  if (x > n) ans = std::min(ans, w[fa[x]]);
  printf("%d\n", ans);
}
int main(void) {
  G.edCnt = 1;
  n = read();
  int m = read(), q = read();
  for (int i = 1; i <= n; ++i) w[i] = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    G.add_edge(x, y);
  }
  tot = n;
  tarjan(1, -1);
  dep[1] = 1;
  dfs1(1);
  dfs2(1, 1);
  for (int now = n + 1; now <= tot; ++now) {
    for (int i = T.ls[now]; i; i = T.e[i].next) {
      if (T.e[i].y == fa[now]) continue;
      set[now].insert(w[T.e[i].y]);
    }
    w[now] = *set[now].begin();
  }
  for (int i = 1; i <= tot; ++i) modify(1, 1, pos[0], pos[i], w[i]);
  for (; q--;) {
    char ch = getchar();
    for (; ch != 'A' && ch != 'C'; ch = getchar())
      ;
    int x = read(), y = read();
    if (ch == 'A')
      solve(x, y);
    else {
      if (fa[x]) set[fa[x]].erase(w[x]);
      w[x] = y;
      modify(1, 1, pos[0], pos[x], y);
      if (fa[x]) {
        set[fa[x]].insert(w[x]);
        w[fa[x]] = *set[fa[x]].begin();
        modify(1, 1, pos[0], pos[fa[x]], w[fa[x]]);
      }
    }
  }
  return 0;
}