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 = 2e5;
vector<int> g[N];
int n;
struct edge {
  int u, v, comp;
  bool bridge;
};
vector<edge> e;
void add_edge(int u, int v) {
  g[u].push_back(e.size());
  g[v].push_back(e.size());
  e.push_back((edge){u, v, -1, false});
}
int D[N], B[N], T;
int nbc, nap;
int art[N];
stack<int> st;
void dfs(int u, int pe) {
  B[u] = D[u] = T++;
  for (int ne : g[u])
    if (ne != pe) {
      int v = e[ne].u ^ e[ne].v ^ u;
      if (D[v] < 0) {
        st.push(ne);
        dfs(v, ne);
        if (B[v] > D[u]) e[ne].bridge = true;
        if (B[v] >= D[u]) {
          art[u]++;
          int last;
          do {
            last = st.top();
            st.pop();
            e[last].comp = nbc;
          } while (last != ne);
          nbc++;
        }
        B[u] = min(B[u], B[v]);
      } else if (D[v] < D[u])
        st.push(ne), B[u] = min(B[u], D[v]);
    }
}
void doit() {
  memset(D, -1, sizeof(D));
  memset(art, 0, sizeof(art));
  nbc = T = 0;
  for (int i = 0; i < n; i++)
    if (D[i] < 0) dfs(i, -1), art[i]--;
}
struct STree {
  vector<int> st;
  int n;
  STree(int n) : st(4 * n + 5, 1e9), n(n) {}
  void init(int k, int s, int e, int *a) {
    if (s + 1 == e) {
      st[k] = a[s];
      return;
    }
    int m = (s + e) / 2;
    init(2 * k, s, m, a);
    init(2 * k + 1, m, e, a);
    st[k] = min(st[2 * k], st[2 * k + 1]);
  }
  void upd(int k, int s, int e, int p, int v) {
    if (s + 1 == e) {
      st[k] = v;
      return;
    }
    int m = (s + e) / 2;
    if (p < m)
      upd(2 * k, s, m, p, v);
    else
      upd(2 * k + 1, m, e, p, v);
    st[k] = min(st[2 * k], st[2 * k + 1]);
  }
  int query(int k, int s, int e, int a, int b) {
    if (s >= b || e <= a) return 1e9;
    if (s >= a && e <= b) return st[k];
    int m = (s + e) / 2;
    return min(query(2 * k, s, m, a, b), query(2 * k + 1, m, e, a, b));
  }
  void init(int *a) { init(1, 0, n, a); }
  void upd(int p, int v) { upd(1, 0, n, p, v); }
  int query(int a, int b) { return query(1, 0, n, a, b); }
};
vector<int> ng[N];
multiset<int> nw[N];
int wg[N], dad[N], dep[N];
void dfs1(int x) {
  wg[x] = 1;
  for (int y : ng[x])
    if (y != dad[x]) {
      dad[y] = x;
      dep[y] = dep[x] + 1;
      dfs1(y);
      wg[x] += wg[y];
    }
}
int curpos, pos[N], head[N];
void hld(int x, int c) {
  if (c < 0) c = x;
  pos[x] = curpos++;
  head[x] = c;
  int mx = -1;
  for (int y : ng[x])
    if (y != dad[x] && (mx < 0 || wg[mx] < wg[y])) mx = y;
  if (mx >= 0) hld(mx, c);
  for (int y : ng[x])
    if (y != mx && y != dad[x]) hld(y, -1);
}
void hld_init() {
  dad[0] = -1;
  dep[0] = 0;
  dfs1(0);
  curpos = 0;
  hld(0, -1);
}
int query(int x, int y, STree &rmq) {
  int r = 1e9;
  while (head[x] != head[y]) {
    if (dep[head[x]] > dep[head[y]]) swap(x, y);
    r = min(r, rmq.query(pos[head[y]], pos[y] + 1));
    y = dad[head[y]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  r = min(r, rmq.query(pos[x], pos[y] + 1));
  if (x < nbc && x != 0) r = min(r, rmq.query(pos[dad[x]], pos[dad[x]] + 1));
  return r;
}
map<int, int> cm;
int w[N];
int main() {
  int m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    add_edge(a, b);
  }
  doit();
  for (int i = 0; i < n; i++)
    if (art[i]) {
      cm[i] = nbc + nap++;
    }
  for (auto ed : e) {
    if (!cm.count(ed.u)) cm[ed.u] = ed.comp;
    if (!cm.count(ed.v)) cm[ed.v] = ed.comp;
  }
  for (auto ed : e) {
    if (art[ed.u]) {
      ng[cm[ed.u]].push_back(ed.comp);
      ng[ed.comp].push_back(cm[ed.u]);
    }
    if (art[ed.v]) {
      ng[cm[ed.v]].push_back(ed.comp);
      ng[ed.comp].push_back(cm[ed.v]);
    }
  }
  for (int i = 0; i < nbc + nap; i++) {
    sort(ng[i].begin(), ng[i].end());
    auto it = unique(ng[i].begin(), ng[i].end());
    ng[i].resize(it - ng[i].begin());
  }
  STree rmq(nbc + nap);
  hld_init();
  for (int i = 0; i < n; i++) {
    int x = cm[i];
    nw[x].insert(w[i]);
    if (x >= nbc) {
      nw[dad[x]].insert(w[i]);
    }
  }
  for (int i = 0; i < nbc + nap; i++) {
    rmq.upd(pos[i], *nw[i].begin());
  }
  while (q--) {
    char o;
    cin >> o;
    if (o == 'A') {
      int a, b;
      cin >> a >> b;
      a--, b--;
      if (a == b)
        cout << w[a] << '\n';
      else
        cout << query(cm[a], cm[b], rmq) << '\n';
    } else {
      int a, ww;
      cin >> a >> ww;
      a--;
      int c = cm[a];
      nw[c].erase(nw[c].find(w[a]));
      nw[c].insert(ww);
      rmq.upd(pos[c], *nw[c].begin());
      if (c >= nbc)
        nw[dad[c]].erase(nw[dad[c]].find(w[a])), nw[dad[c]].insert(ww),
            rmq.upd(pos[dad[c]], *nw[dad[c]].begin());
      w[a] = ww;
    }
  }
  return 0;
}