Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
A. Headquarters

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputSensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters each occupies exactly one point on the two-dimensional kingdom.

The outlaw's car was equipped with a GPS transmitter. The transmitter showed that the car made exactly *n* movements on its way from the headquarters to the stall. A movement can move the car from point (*x*, *y*) to one of these four points: to point (*x* - 1, *y*) which we will mark by letter "L", to point (*x* + 1, *y*) — "R", to point (*x*, *y* - 1) — "D", to point (*x*, *y* + 1) — "U".

The GPS transmitter is very inaccurate and it doesn't preserve the exact sequence of the car's movements. Instead, it keeps records of the car's possible movements. Each record is a string of one of these types: "UL", "UR", "DL", "DR" or "ULDR". Each such string means that the car made a single movement corresponding to one of the characters of the string. For example, string "UL" means that the car moved either "U", or "L".

You've received the journal with the outlaw's possible movements from the headquarters to the stall. The journal records are given in a chronological order. Given that the ice-cream stall is located at point (0, 0), your task is to print the number of different points that can contain the gang headquarters (that is, the number of different possible locations of the car's origin).

Input

The first line contains a single integer *n* (1 ≤ *n* ≤ 2·10^{5}) — the number of the car's movements from the headquarters to the stall.

Each of the following *n* lines describes the car's possible movements. It is guaranteed that each possible movement is one of the following strings: "UL", "UR", "DL", "DR" or "ULDR".

All movements are given in chronological order.

Please do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin and cout stream or the %I64d specifier.

Output

Print a single integer — the number of different possible locations of the gang's headquarters.

Examples

Input

3

UR

UL

ULDR

Output

9

Input

2

DR

DL

Output

4

Note

The figure below shows the nine possible positions of the gang headquarters from the first sample:

For example, the following movements can get the car from point (1, 0) to point (0, 0):

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/12/2021 01:23:56 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|