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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return l + rng() % (r - l + 1); }
const int N = 300010;
int n, m, it, top, scc, q;
int num[N], low[N], st[N], sz[N], d[N], tin[N], tout[N], root[N], w[N], id[N];
int T[N * 4];
int f[N][21];
vector<int> ad[N], adj[N];
multiset<int> h[N];
void tja(int u, int p = -1) {
  num[u] = low[u] = ++it;
  st[++top] = u;
  for (auto& v : ad[u])
    if (v != p) {
      if (!num[v]) {
        tja(v, u);
        low[u] = min(low[u], low[v]);
        if (num[u] <= low[v]) {
          scc++;
          int x;
          do {
            x = st[top--];
            adj[scc].push_back(x);
            h[scc].insert(w[x]);
          } while (x != v);
          adj[u].push_back(scc);
          w[scc] = *h[scc].begin();
        }
      } else
        low[u] = min(low[u], num[v]);
    }
}
void dfs(int u, int p = -1) {
  sz[u] = 1;
  for (int i = 1, _c = 20; i <= _c; ++i) f[u][i] = f[f[u][i - 1]][i - 1];
  for (auto& v : adj[u])
    if (v != p) {
      f[v][0] = u;
      dfs(v, u);
      sz[u] += sz[v];
      if (sz[d[u]] < sz[v]) d[u] = v;
    }
}
void hld(int u, int p = -1) {
  if (!root[u]) root[u] = u;
  tin[u] = ++it;
  id[it] = u;
  if (d[u]) root[d[u]] = root[u], hld(d[u], u);
  for (auto& v : adj[u])
    if (v != p && v != d[u]) {
      hld(v, u);
    }
  tout[u] = it;
}
int anc(int u, int v) { return tin[u] <= tin[v] && tout[u] >= tout[v]; }
int lca(int u, int v) {
  if (anc(u, v)) return u;
  if (anc(v, u)) return v;
  for (int i = 20, _c = 0; i >= _c; --i)
    if (!anc(f[u][i], v)) u = f[u][i];
  return f[u][0];
}
void build(int s, int l, int r) {
  if (l == r) {
    T[s] = w[id[l]];
    return;
  }
  int m = (l + r) / 2;
  build(2 * s, l, m);
  build(2 * s + 1, m + 1, r);
  T[s] = min(T[2 * s], T[2 * s + 1]);
}
void upd(int s, int l, int r, int i, int x) {
  if (l > i || i > r) return;
  if (l == r) {
    T[s] = x;
    return;
  }
  int m = (l + r) / 2;
  upd(2 * s, l, m, i, x);
  upd(2 * s + 1, m + 1, r, i, x);
  T[s] = min(T[2 * s], T[2 * s + 1]);
}
int get(int s, int l, int r, int u, int v) {
  if (l > v || u > r) return INT_MAX;
  if (u <= l && r <= v) return T[s];
  int m = (l + r) / 2;
  return min(get(2 * s, l, m, u, v), get(2 * s + 1, m + 1, r, u, v));
}
void mod(int u, int x) {
  upd(1, 1, scc, tin[u], x);
  int v = f[u][0];
  if (v) {
    h[v].erase(h[v].find(w[u]));
    h[v].insert(x);
    w[v] = *h[v].begin();
    upd(1, 1, scc, tin[v], w[v]);
  }
  w[u] = x;
}
int cost(int u, int p) {
  int ret = w[p];
  while (u != p) {
    if (u == root[u])
      ret = min(ret, get(1, 1, scc, tin[u], tin[u])), u = f[u][0];
    else if (anc(root[u], p))
      ret = min(ret, get(1, 1, scc, tin[p], tin[u])), u = p;
    else
      ret = min(ret, get(1, 1, scc, tin[root[u]], tin[u])), u = f[root[u]][0];
  }
  return ret;
}
int que(int u, int v) {
  int p = lca(u, v);
  return min({cost(u, p), cost(v, p), p > n ? w[f[p][0]] : INT_MAX});
}
int main() {
  n = scc = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  m = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
  q = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  });
  for (int i = 1, _c = n; i <= _c; ++i)
    w[i] = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
    h[i].insert(w[i]);
  for (int i = 1, _c = m; i <= _c; ++i) {
    int u = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
        v = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        });
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  for (int i = 1, _c = n; i <= _c; ++i)
    if (!num[i]) tja(i);
  f[1][0] = 1;
  it = 0;
  dfs(1);
  it = 0;
  hld(1);
  build(1, 1, scc);
  for (int i = 1, _c = q; i <= _c; ++i) {
    char ch;
    while (!isupper(ch = getchar()))
      ;
    int x = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
        y = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        });
    if (ch == 'C') {
      mod(x, y);
    } else {
      cout << que(x, y) << "\n";
    }
  }
}