No tags yet

No tag edit access

time limit per test: 1.25 sec.

memory limit per test: 65536 KB

memory limit per test: 65536 KB

input: standard

output: standard

output: standard

You have given the square NxN on a checkered sheet. Size of each cell is 1x1, (1, 1) is leftmost top corner and (N, N) is rightmost bottom corner.

Initially all cells are white.

There are M repaintings inside of the square, where one repainting changes color of specified rectangle to some color (white or black). All sides of repainted rectangles are parallel to sides of square.

You need to find amount of white cells after all repaintings.

Initially all cells are white.

There are M repaintings inside of the square, where one repainting changes color of specified rectangle to some color (white or black). All sides of repainted rectangles are parallel to sides of square.

You need to find amount of white cells after all repaintings.

The first line of input consists of two numbers N and M (1<=N<=1000, 1<=M<=5000). Each of the next M lines consists of X1 Y1 X2 Y2 C, where (X1, Y1) and (X2, Y2) are indexes of opposite corners of the rectangular, and C is a symbol 'b' or 'w' ('b' means black color and 'w' - white) (1<=X1,X2,Y1,Y2<=N). All numbers in input are integer.

Write amount of white cells after all repaintings.

Input

9 6

2 2 4 6 b

4 3 3 3 w

6 2 8 6 b

5 3 6 9 w

8 3 9 9 w

1 5 3 5 w

2 2 4 6 b

4 3 3 3 w

6 2 8 6 b

5 3 6 9 w

8 3 9 9 w

1 5 3 5 w

Output

63

Author: | Stanislav Angelyuk |

Resource: | Saratov ST team Spring Contest #1 |

Date: | 18.05.2003 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/24/2019 03:40:14 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|