Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

C. Crossings With Danger
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
5 6 7
2 2 O
3 2 N
4 2 N
4 5 N
2 6 O
5 5 L
2 4 O
Output
4
Input
2 2 3
1 1 L
1 2 O
2 2 N
Output
0
Input
2 2 3
1 1 L
1 2 O
2 1 N
Output
1