Counting
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

people are wandering in the city from second to the -th second. They are numbered from to . The city can be viewed as a grid, and the top left square is .

The -th person is standing at square at first. For each second, every person will move to an adjacent square. Two squares are adjacent if and only if they share a common edge. In each -th second (), the -th person's move can be described as a character .

Let be the current square of this person in the -th second, and be the position where he/she will appear in the -th second, then:

Define as the number of different pairs such that and person and are in the same square in the -th second.

In order to know how many pairs of these people will meet in the -th second, you need to calculate the value .

It is guaranteed that every person's location in every second is legal. Formally speaking, let be the -th person's location, then always satisfied.

输入描述:

The first line contains four positive integers  .

The next  lines contain two integers. The -th line contains two integers   separated by a space, indicating the -th person's location in  second.

The next  lines contains a string of length  in each line. The -th character in the -th line's string  represents the -th person's move in second , which is .

输出描述:

There are  lines in the output.

The -th line contains a single integer , indicating the number of different pairs  such that  and person  and  are in the same square in the -th second.

示例1

输入

复制
2 2 2 1
1 1
2 2
R
U

输出

复制
0
1