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

#include <cstdio>
#include <cassert>
#include <cstring>
#include <bitset>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

const int N = 400;
const int M1 = (int)1e9 + 9;
const int M2 = (int)1e9 + 7;

int n, q;
unsigned A, B, koef[N][N];
ll f[N][N];

int main()
{
  #define NAME "reachability"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  assert(scanf("%d%d%u%u", &n, &q, &A, &B) == 4 && n <= N); // no overflow
  koef[0][0] = 1;
  forn(i, n - 1)
    koef[i + 1][0] = koef[i][0] * A;
  forn(i, n)
    forn(j, n - 1)
      koef[i][j + 1] = koef[i][j] * B;

  while (q--)
  {
    char com, type;
    int v, k, a;
    scanf(" %c %c%d%d", &com, &type, &v, &k), v--;

    forn(a, n)
      if (f[a][v] && a != v)
        forn(b, n)
          if (f[v][b])
            f[a][b] = f[a][b] - f[a][v] * f[v][b];

    while (k--)
    {
      scanf("%d", &a), a--;
      if (type == 'o' && com == '+')
        forn(i, n)
          f[v][i] = f[v][i] + (f[a][i] + (i == a));
      else if (type == 'i' && com == '+')
        forn(i, n)
          f[i][v] = f[i][v] + (f[i][a] + (i == a));
      else if (type == 'o' && com == '-')
        forn(i, n)
          f[v][i] = f[v][i] - (f[a][i] + (i == a));
      else if (type == 'i' && com == '-')
        forn(i, n)
          f[i][v] = f[i][v] - (f[i][a] + (i == a));
      else
        assert(0);
    }

    forn(a, n)
      if (f[a][v] && a != v)
        forn(b, n)
          if (f[v][b])
            f[a][b] = f[a][b] + f[a][v] * f[v][b];

    unsigned sum = 0;
    forn(i, n)
      forn(j, n)
      {
        if (f[i][j])
          f[i][j] %= M1;
        if (i != j && f[i][j])
          sum += koef[i][j];
      }
    printf("%u\n", sum);
  }
  return 0;
}
