2200. The number of symmetrical choices

单点时限: 2.0 sec

内存限制: 256 MB

We are given two sequences of words: (x1,…,xn) and (y1,…,yn), 1 <= n <= 30. For every i, 1<=i<=n, we chose one of the two words: xi or yi. The chosen words are merged in order of increasing indices. The choice consists of n steps. In each step we decide to take the i-th word from the first or from the second sequence of words. More formally: the choice is a sequence of length n whose elements are numbers 1 and 2. It is possible that different choices lead to the same word. We say that a choice is symmetrical if its result is a palindrome, i.e. a word that is identical when we read it from left to right and from right to left.

Task

Write a program that:

  • reads the number n and two sequences of words (x1,…,xn) and (y1,…,yn),

  • computes the number of symmetrical choices for the given sequences,

  • writes the result.

输入格式

In the first line there is one positive integer n <= 30. In the following n lines there are written consecutive words of the sequence (xi) - one word in one line. In the following n lines there are written (in the similar way) consecutive words of the sequence (yi). Each word consists solely of small letters of the English alphabet (from a to z) and its length is from the range [1..400].

输出格式

there should be written one non-negative integer - the number of symmetrical choices.

样例

Input
5
ab
a
a
ab
a
a
baaaa
a
a
ba
Output
12

0 人解决,1 人已尝试。

0 份提交通过,共有 1 份提交。

9.9 EMB 奖励。

创建: 16 年前.

修改: 6 年,11 月前.

最后提交: 13 年,5 月前.

来源: POI 1997 I Stage

题目标签