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;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int fh = 1;
  while (!isdigit(c)) {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= fh;
}
struct Info {
  int nu, ne;
} a[400010 * 2], na[400010 * 2];
struct seg {
  int l, r, mi;
} t[400010 * 4];
int num, b[400010], m, n, x, y, lo[400010], df[400010], su, q, nu, nb[400010],
    nst, st[400010], va[400010], f[400010], d[400010], si[400010], so[400010],
    tp[400010], bi[400010];
multiset<int> v[400010];
void jb(int x, int y) {
  a[++num].nu = y;
  a[num].ne = b[x];
  b[x] = num;
}
void jnb(int x, int y) {
  na[++nu].nu = y;
  na[nu].ne = nb[x];
  nb[x] = nu;
}
void tarjan(int x, int fa) {
  lo[x] = df[x] = ++num;
  st[++nst] = x;
  for (int y = nb[x]; y; y = na[y].ne) {
    if (na[y].nu != fa) {
      if (!df[na[y].nu]) {
        tarjan(na[y].nu, x);
        lo[x] = min(lo[x], lo[na[y].nu]);
        if (lo[na[y].nu] >= df[x]) {
          jb(x, ++su);
          jb(su, x);
          while (st[nst] != na[y].nu) {
            jb(su, st[nst]);
            jb(st[nst], su);
            nst--;
          }
          jb(su, st[nst]);
          jb(st[nst], su);
          nst--;
        }
      } else
        lo[x] = min(lo[x], df[na[y].nu]);
    }
  }
}
void dfs(int x, int fa, int dep) {
  f[x] = fa;
  d[x] = dep;
  si[x] = 1;
  for (int y = b[x]; y; y = a[y].ne) {
    if (a[y].nu != fa) {
      dfs(a[y].nu, x, dep + 1);
      if (x > n) {
        v[x].insert(va[a[y].nu]);
      }
      si[x] += si[a[y].nu];
      if (si[a[y].nu] > si[so[x]]) so[x] = a[y].nu;
    }
  }
}
void dfs1(int x) {
  bi[x] = ++num;
  if (so[x] != 0) {
    tp[so[x]] = tp[x];
    dfs1(so[x]);
  }
  for (int y = b[x]; y; y = a[y].ne) {
    if (a[y].nu != f[x] && a[y].nu != so[x]) {
      tp[a[y].nu] = a[y].nu;
      dfs1(a[y].nu);
    }
  }
}
int quem(int nu, int l, int r) {
  if (t[nu].l == l && t[nu].r == r) return t[nu].mi;
  int mid = (t[nu].l + t[nu].r) / 2;
  if (l > mid) return quem(nu * 2 + 1, l, r);
  if (r <= mid) return quem(nu * 2, l, r);
  return min(quem(nu * 2, l, mid), quem(nu * 2 + 1, mid + 1, r));
}
int que(int x, int y) {
  int no = 1e9;
  while (tp[x] != tp[y]) {
    if (d[tp[x]] < d[tp[y]]) swap(x, y);
    no = min(no, quem(1, bi[tp[x]], bi[x]));
    x = f[tp[x]];
  }
  if (d[x] > d[y]) swap(x, y);
  no = min(no, quem(1, bi[x], bi[y]));
  if (x > n) no = min(no, quem(1, bi[f[x]], bi[f[x]]));
  return no;
}
void build(int nu, int l, int r) {
  t[nu].l = l;
  t[nu].r = r;
  t[nu].mi = 0;
  if (l != r) {
    build(nu * 2, l, (l + r) / 2);
    build(nu * 2 + 1, (l + r) / 2 + 1, r);
    t[nu].mi = min(t[nu * 2].mi, t[nu * 2 + 1].mi);
  }
}
int man(int x) {
  multiset<int>::iterator i = v[x].begin();
  return *i;
}
void chan(int nu, int we, int x) {
  if (t[nu].l == t[nu].r) {
    t[nu].mi = x;
    return;
  }
  if (we <= (t[nu].l + t[nu].r) / 2)
    chan(nu * 2, we, x);
  else
    chan(nu * 2 + 1, we, x);
  t[nu].mi = min(t[nu * 2].mi, t[nu * 2 + 1].mi);
}
void work(int x, int y, int z) {
  multiset<int>::iterator i = v[x].find(y);
  v[x].erase(i);
  v[x].insert(z);
  chan(1, bi[x], man(x));
}
int main() {
  read(n);
  read(m);
  read(q);
  su = n;
  for (int i = 1; i <= n; i++) read(va[i]);
  for (int i = 1; i <= m; i++) {
    read(x);
    read(y);
    jnb(x, y);
    jnb(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!df[i]) tarjan(i, 0);
  dfs(1, 0, 1);
  tp[1] = 1;
  num = 0;
  dfs1(1);
  build(1, 1, su);
  for (int i = 1; i <= su; i++)
    if (i <= n)
      chan(1, bi[i], va[i]);
    else
      chan(1, bi[i], man(i));
  while (q--) {
    char ch = getchar();
    while (ch != 'A' && ch != 'C') ch = getchar();
    if (ch == 'A') {
      read(x);
      read(y);
      printf("%d\n", que(x, y));
    } else {
      read(x);
      read(y);
      chan(1, bi[x], y);
      if (f[x]) work(f[x], va[x], y);
      va[x] = y;
    }
  }
  return 0;
}