% Author: Sergey Kopeliovich
% Source: SPBU Championship, October 2013

\gdef\thisproblemauthor{Sergey Kopeliovich}
\gdef\thisproblemdeveloper{Sergey Kopeliovich}

\begin{problem}{Reachability}
{reachability.in}{reachability.out}
{3 seconds (\textsl{8 seconds for Java})}{256 mebibytes}{}

You are given an oriented graph of $n$ vertices.
Initially there are no edges.

We will denote an edge from $a$ to $b$ as $(a, b)$.

You have to process the following four types of queries:

\begin{MyList}
  \item ``\t{+ o $v$ $k$ $a_1$ $\dots$ $a_k$}'': add edges
        $(v, a_1), \dots, (v, a_k)$
  \item ``\t{+ i $v$ $k$ $a_1$ $\dots$ $a_k$}'': add edges
        $(a_1, v), \dots, (a_k, v)$
  \item ``\t{- o $v$ $k$ $a_1$ $\dots$ $a_k$}'': delete edges
        $(v, a_1), \dots, (v, a_k)$
  \item ``\t{- i $v$ $k$ $a_1$ $\dots$ $a_k$}'': delete edges
        $(a_1, v), \dots, (a_k, v)$
\end{MyList}

In each query, all $a_i$ are different.

If you have to add an edge, it is guaranteed that there was no such edge
in the graph.

If you have to delete an edge, it is guaranteed that there was such edge
in the graph.

Also it is guaranteed that at each moment of time, the graph has no cycles.

You task is to maintain the matrix of reachability:

$$a_{ij} = \begin{cases} 1 \text{, if } i \not= j \text{ and from } i
 \text{ there is a path to } j \text{ using edges of the graph}
 \\ 0 \text{, otherwise} \end{cases}$$

\InputFile

The first line of input contains integers $n$,
the number of vertices in the graph, $q$, the number of queries,
and also $A$ and $B$ which will be useful for output
($1 \le n \le 400$, $1 \le q \le 800$, $1 \le A, B \le 10^9$).
Next $q$ lines contain queries in the format described above, one per line.

\OutputFile

After each query, output the value of expression
$$\left(\sum\limits_{i, j = 1}^{n} a_{ij} A^i B^j\right) \bmod 2^{32}$$
on a separate line.

\Example

\begin{example}
\exmp{
2 4 3 7
+ o 1 1 2
- i 2 1 1
+ i 1 1 2
- o 2 1 1
}{
7
0
3
0
}%
\end{example}

\end{problem}
