**S. 13.** Two players alternately move a piece on the vertices of a directed graph. One loses if he or she cannot move because the current vertex has no outward edge. If the piece is placed for the third time onto the same vertex, the game is a draw. Write a program that determines for each vertex the best possible result of the first player starting from that position.

The program will be run from the command line with two parameters containing the names of the input and output files. The input file contains the graph. The output file should contain whether any given vertex is a winning or a losing one.

The first line of the input file will contain the number of vertices and edges (*n*,*m*). The vertices are numbered from 1 to *n*. The next *m* lines will contain the origin and endpoint of each directed edge. The output file should have *n* lines, with the line containing `W`, `D` or `L`, depending on whether the first player starting from the vertex has a winning strategy, both players have a strategy to force a draw, or the second player has a winning strategy, respectively.

The graph can be assumed to have at most 1 000 000 vertices and at most 50 000 000 edges.

*Example:* the program is run with `s13 graph.txt result.txt` parameters.

`graf.txt` | `result.txt` |

`5 7` 1 1 1 2 2 3 2 4 3 1 4 3 4 5 | `D` D D W L |

The source code of the program (`s13.pas`, `s13.cpp`, ...) should be submitted.

(10 points)

**Deadline expired on 16 January 2006.**