Problem: User ainta decided to make a new instant messenger called "aintalk". With aintalk, each user can chat with other people. User ainta made the prototype of some functions to implement this thing.

  1. login(u): User u logins into aintalk and becomes online. 
  2. logout(u): User u logouts and becomes offline. 
  3. add_friend(u, v): User u and user v become friends. It means, u and v can talk with each other. The friendship is bidirectional. 
  4. del_friend(u, v): Unfriend user u and user v. It means, u and v cannot talk with each other from then. 
  5. count_online_friends(u): The function returns the number of friends of user u who are online at the moment. 



Because the messenger is being tested by some users numbered from 1 to n, there is no register method. This means, at the beginning, some users may be online, and some users may have friends.

User ainta is going to make these functions, but before making the messenger public, he wants to know whether he is correct. Help ainta verify his code.

Input

The first line contains three space-separated integers n, m and q (1 ≤ n ≤ 50000; 1 ≤ m ≤ 150000; 1 ≤ q ≤ 250000) — the number of users, the number of pairs of friends, and the number of queries.

The second line contains an integer o (1 ≤ o ≤ n) — the number of online users at the beginning. The third line contains o space-separated integers x1, x2, ..., xo (1 ≤ xi ≤ n) — the ids of the online users. It is guaranteed that these values are distinct.

Each of the next m lines contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi) — the ids of two users who are friends at the beginning. It is guaranteed there are no multiple friendship given in the input. Note that the friendship is bidirectional.

Next q lines describe the q queries in the format:

  * "O u" (1 ≤ u ≤ n) : Call online(u). It is guaranteed that user u was offline just before the function call. 
  * "F u" (1 ≤ u ≤ n) : Call offline(u). It is guaranteed that user u was online just before the function call. 
  * "A u v" (1 ≤ u, v ≤ n; u ≠ v) : Call add_friend(u, v). It is guaranteed that these two users weren't friends just before the function call. 
  * "D u v" (1 ≤ u, v ≤ n; u ≠ v) : Call del_friend(u, v). It is guaranteed that these two users were friends just before the function call. 
  * "C u" (1 ≤ u ≤ n) : Call count_online_friends(u) and print the result in a single line. 

Output

For each count_online_friends(u) query, print the required answer in a single line. 

Examples

Input

5 2 9
1
4
1 3
3 4
C 3
A 2 5
O 1
D 1 3
A 1 2
A 4 2
C 2
F 4
C 2


Output

1
2
1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 50005;
const int M = 150005;
const int Q = 250005;
int n, m, q;
int eu[M + Q], ev[M + Q], ew[M + Q], es;
unordered_map<long long, int> vis;
bool online[N], is_pop[N];
int cache[N], deg[N];
char qc[Q][2];
int qu[Q], qv[Q], qe[Q];
vector<int> adj[N], elite[N];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  int o;
  scanf("%d", &o);
  for (int i = 0; i < o; ++i) {
    int x;
    scanf("%d", &x);
    online[x] = true;
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v) continue;
    if (u > v) swap(u, v);
    long long id = 1ll * u * N + v;
    if (vis.count(id)) continue;
    vis[id] = es;
    eu[es] = u;
    ev[es] = v;
    ew[es] = 1;
    es++;
  }
  for (int i = 0; i < q; ++i) {
    scanf("%s%d", qc[i], &qu[i]);
    switch (*qc[i]) {
      case 'A':
      case 'D': {
        scanf("%d", &qv[i]);
        int& u = qu[i];
        int& v = qv[i];
        if (u > v) swap(u, v);
        if (u == v) break;
        long long id = 1ll * u * N + v;
        int e;
        if (vis.count(id)) {
          e = vis[id];
        } else {
          e = es++;
          vis[id] = e;
        }
        eu[e] = u;
        ev[e] = v;
        qe[i] = e;
        break;
      }
    }
  }
  for (int i = 0; i < es; ++i) {
    adj[eu[i]].push_back(i), adj[ev[i]].push_back(i);
  }
  int sN = sqrt(2 * n) + 1;
  for (int i = 1; i <= n; ++i) {
    deg[i] = adj[i].size();
    is_pop[i] = (deg[i] >= sN);
  }
  for (int i = 1; i <= n; ++i) {
    for (int e : adj[i]) {
      int v = eu[e] == i ? ev[e] : eu[e];
      if (is_pop[v]) {
        elite[i].push_back(e);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (online[i] && !is_pop[i]) {
      for (int e : adj[i]) {
        if (!ew[e]) continue;
        int v = eu[e] == i ? ev[e] : eu[e];
        cache[v] += 1;
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    switch (*qc[i]) {
      case 'O': {
        int u = qu[i];
        online[u] = true;
        if (!is_pop[u]) {
          for (int e : adj[u]) {
            if (!ew[e]) continue;
            int v = eu[e] == u ? ev[e] : eu[e];
            cache[v] += 1;
          }
        }
        break;
      }
      case 'F': {
        int u = qu[i];
        online[u] = false;
        if (!is_pop[u]) {
          for (int e : adj[u]) {
            if (!ew[e]) continue;
            int v = eu[e] == u ? ev[e] : eu[e];
            cache[v] -= 1;
          }
        }
        break;
      }
      case 'A': {
        int u = qu[i];
        int v = qv[i];
        int e = qe[i];
        ew[e] = true;
        if (!is_pop[u] && online[u]) cache[v] += 1;
        if (!is_pop[v] && online[v]) cache[u] += 1;
        break;
      }
      case 'D': {
        int u = qu[i];
        int v = qv[i];
        int e = qe[i];
        ew[e] = false;
        if (!is_pop[u] && online[u]) cache[v] -= 1;
        if (!is_pop[v] && online[v]) cache[u] -= 1;
        break;
      }
      case 'C': {
        int u = qu[i];
        int friends = cache[u];
        for (int e : elite[u]) {
          if (!ew[e]) continue;
          int v = eu[e] == u ? ev[e] : eu[e];
          if (online[v]) friends += 1;
        }
        printf("%d\n", friends);
      }
    }
  }
}