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;
vector<int> vec[100010];
struct node {
  int y, next;
} a[400010];
int len = 1, last[200010];
void ins(int x, int y) {
  a[++len].y = y;
  a[len].next = last[x];
  last[x] = len;
}
int w[200010], n, m, Q, A[200010];
int dfn[100010], low[100010], sta[100010], top = 0, id = 0, cnt;
void tarjan(int x, int fa) {
  low[x] = dfn[x] = ++id;
  sta[++top] = x;
  for (int i = last[x]; i; i = a[i].next) {
    if (i == (fa ^ 1)) continue;
    int y = a[i].y;
    if (dfn[y] == -1) {
      tarjan(y, i);
      if (low[y] >= dfn[x]) {
        cnt++;
        while (1) {
          int t = sta[top--];
          vec[cnt].push_back(t);
          if (t == y) break;
        }
        vec[cnt].push_back(x);
      } else
        low[x] = min(low[x], low[y]);
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
struct trnode {
  int tot, top, fa, dep, son, lc, rc, c;
} tr[400010];
int tot = 0;
int ys[200010], z = 0;
void pre_node(int x, int fa) {
  tr[x].tot = 1;
  tr[x].fa = fa;
  tr[x].dep = tr[fa].dep + 1;
  for (int i = last[x]; i; i = a[i].next) {
    int y = a[i].y;
    if (y == fa) continue;
    pre_node(y, x);
    tr[x].tot += tr[y].tot;
    if (tr[tr[x].son].tot < tr[y].tot) tr[x].son = y;
  }
}
void pre_edge(int x, int top) {
  ys[x] = ++z;
  tr[x].top = top;
  if (tr[x].son) pre_edge(tr[x].son, top);
  for (int i = last[x]; i; i = a[i].next) {
    int y = a[i].y;
    if (y != tr[x].fa && y != tr[x].son) pre_edge(y, y);
  }
}
struct Priority_queue {
  priority_queue<int, vector<int>, greater<int> > q1, q2;
  Priority_queue() {
    while (!q1.empty()) q1.pop();
    while (!q2.empty()) q2.pop();
  }
  void push(int x) { q1.push(x); }
  void del(int x) { q2.push(x); }
  int top() {
    while (!q1.empty() && !q2.empty() && q1.top() == q2.top())
      q1.pop(), q2.pop();
    return q1.top();
  }
} q[200010];
int bt(int l, int r) {
  int x = ++tot;
  if (l != r) {
    int mid = (l + r) / 2;
    tr[x].lc = bt(l, mid);
    tr[x].rc = bt(mid + 1, r);
    tr[x].c = min(tr[tr[x].lc].c, tr[tr[x].rc].c);
  } else
    tr[x].c = A[l];
  return x;
}
void change(int x, int l, int r, int k, int c) {
  if (l == r) {
    tr[x].c = c;
    return;
  }
  int mid = (l + r) / 2;
  if (k <= mid)
    change(tr[x].lc, l, mid, k, c);
  else
    change(tr[x].rc, mid + 1, r, k, c);
  tr[x].c = min(tr[tr[x].lc].c, tr[tr[x].rc].c);
}
int findans(int x, int l, int r, int fl, int fr) {
  if (l == fl && r == fr) return tr[x].c;
  int mid = (l + r) / 2;
  if (fr <= mid) return findans(tr[x].lc, l, mid, fl, fr);
  if (fl > mid) return findans(tr[x].rc, mid + 1, r, fl, fr);
  return min(findans(tr[x].lc, l, mid, fl, mid),
             findans(tr[x].rc, mid + 1, r, mid + 1, fr));
}
int solve(int x, int y) {
  int tx = tr[x].top, ty = tr[y].top, ans = 1e9 + 7;
  while (tx != ty) {
    if (tr[tx].dep < tr[ty].dep) swap(tx, ty), swap(x, y);
    ans = min(ans, findans(1, 1, n + cnt, ys[tx], ys[x]));
    x = tr[tx].fa;
    tx = tr[x].top;
  }
  if (tr[x].dep < tr[y].dep) swap(x, y);
  ans = min(ans, findans(1, 1, n + cnt, ys[y], ys[x]));
  if (y > n) ans = min(ans, w[tr[y].fa]);
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &m, &Q);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    ins(x, y);
    ins(y, x);
  }
  memset(dfn, -1, sizeof(dfn));
  tarjan(1, 0);
  len = 0;
  memset(last, 0, sizeof(last));
  for (int i = 1; i <= cnt; i++) {
    int x = i + n;
    for (int j = 0; j < vec[i].size(); j++) {
      int y = vec[i][j];
      ins(x, y);
      ins(y, x);
    }
  }
  pre_node(1, 0);
  pre_edge(1, 1);
  for (int i = 1; i <= cnt; i++) {
    int x = i + n;
    for (int j = 0; j < vec[i].size(); j++) {
      int y = vec[i][j];
      if (y == tr[x].fa) continue;
      q[x].push(w[y]);
    }
    w[x] = q[x].top();
  }
  for (int i = 1; i <= n + cnt; i++) A[ys[i]] = w[i];
  bt(1, n + cnt);
  while (Q--) {
    char ch[2];
    scanf("%s", ch);
    int x, y;
    scanf("%d %d", &x, &y);
    if (ch[0] == 'C') {
      if (tr[x].fa) q[tr[x].fa].del(w[x]);
      w[x] = y;
      change(1, 1, n + cnt, ys[x], w[x]);
      if (tr[x].fa)
        q[tr[x].fa].push(w[x]),
            w[tr[x].fa] = q[tr[x].fa].top(),
            change(1, 1, n + cnt, ys[tr[x].fa], w[tr[x].fa]);
    } else
      printf("%d\n", solve(x, y));
  }
}