TPCPALIN - Palindrome Merge

Given two strings s1 and s2. We can merge characters of two strings (with order in original strings) to get a new string.

For example : s1 = 'ab' and s2 = 'ba'.

We can merge to get st = 'abba' but not st = 'aabb'.

The Problem : Given two string contain only lowercase letters, count the number of palindrome by merging in different ways. 

Example: 'aba', 'abba' are palindrome, 'abc' and 'abca' aren't.

Input

- Two lines, each line contains a string, string's length isn't over 500.

Output

- A single integer is the number of palindrome after modulo 3210121.

Example

Input:
ab
ba

Output:
4


Được gửi lên bởi:Mew.
Ngày:2014-09-21
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ASM64 GOSU PERL6 PYPY RUST SED

hide comments
2018-06-18 06:22:29
Code AC: https://bit.ly/2LV84yg
2018-06-18 06:22:25
Code AC: https://bit.ly/2LV84yg
2014-09-30 15:15:13 m
vào top 50 là up bài ngay
:v
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.