/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Date: 2013.10.05
 *
 * Status: Accepted, Time = 5.19
 */

import java.util.*;
import java.io.*;
import java.math.*;

public class reachability_sk_nm_32 {

	final int N = 400;
	final int E = N * N / 2;

	int n, q, n1;
	int A, B, koef[][] = new int[N][N];
	boolean c[][] = new boolean[N][N];
	int e, head[] = new int[N], next[] = new int[E], to[] = new int[E];
	int cc, u[] = new int[N];
	int is[][] = new int[N][N / 32 + 1];

	void calc( int v ) {
		u[v] = cc;
		for (int e = head[v]; e != 0; e = next[e]) {
			int x = to[e];
			if (u[x] != cc) {
				calc(x);
			}
			for (int i = 0; i < n1; i++) {
				is[v][i] |= is[x][i];
			}
		}
		is[v][v >> 5] |= 1 << (v & 31);
	}

	StreamTokenizer in;
	PrintWriter out;
	
	int nextInt() throws IOException {
		in.nextToken();
		return (int)in.nval;
	}

	String nextWord() throws IOException {
		in.nextToken();
		return in.sval;
	}

	public void run() throws IOException {
		final String NAME = "reachability";
		in = new StreamTokenizer(new BufferedReader(new FileReader(NAME + ".in")));
		PrintWriter out = new PrintWriter(new File(NAME + ".out"));

		n = nextInt();
		q = nextInt();
		A = nextInt();
		B = nextInt();

		n1 = (n >> 5) + 1;
		koef[0][0] = 1;
		for (int i = 0; i < n - 1; i++) {
			koef[i + 1][0] = koef[i][0] * A;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n - 1; j++) {
				koef[i][j + 1] = koef[i][j] * B;
			}
		}
		while (q --> 0) {
			in.nextToken(); // skip it
			char type = nextWord().charAt(0);
			int x = nextInt() - 1;
			int k = nextInt();
			while (k --> 0) {
				int a = nextInt() - 1;
				if (type == 'o') {
					c[x][a] = !c[x][a];
				} else {
					c[a][x] = !c[a][x];
				}
			}
			e = 1;
			Arrays.fill(head, 0);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (c[i][j]) {
						next[e] = head[i];
						to[e] = j;
						head[i] = e++;
					}
				}
			}

			int sum = 0;
			cc++;
			for (int i = 0; i < n; i++) {
				Arrays.fill(is[i], 0);
			}
			for (int v = 0; v < n; v++) {
				if (u[v] != cc) {
					calc(v);
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i != j && ((is[i][j >> 5] >>> (j & 31)) & 1) == 1) {
						sum += koef[i][j];
					}
				}
			}

			long ans = sum;
			out.println(ans >= 0 ? ans : (ans + (1L << 32)));
		}
		out.close();
	}

	static public void main(String[] args) throws Exception {
		new reachability_sk_nm_32().run();
	}
}
