#C2979. Unique Workspace Areas

    ID: 46354 Type: Default 1000ms 256MiB

Unique Workspace Areas

Unique Workspace Areas

You are given multiple configurations of a robotic arm. Each configuration consists of a number of segments and joints between them. For each configuration, if there is at least one joint of type S, the workspace area is calculated using the formula:

\( \text{area} = \pi \sum_{i=1}^{L} {l_i^2} \)

Otherwise, if no joint is of type S, the workspace area is defined as the simple sum of the segment lengths:

\( \text{area} = \sum_{i=1}^{L} l_i \)

Your task is to determine the number of unique workspace areas among all configurations.

inputFormat

The first line contains two integers N and L, where N is the number of robotic arm configurations and L is the number of segments in each configuration.

The next N lines each contain L space-separated integers representing the lengths of the segments for each configuration.

The following N lines each contain L-1 space-separated tokens representing the joint types between segments. Each token is either S or another character (for example, F).

outputFormat

Print a single integer representing the number of unique workspace areas.

## sample
2 3
5 10 10
2 2 2
F S
S S
2