P24925 [AtCoder] Perfect Strings
NOI
题目描述

Problem Statement

There are positive integers N and M.
A binary string s is called good if all of the followings are satisfied:

  • s is non-empty.
  • The number of 1s in s is a multiple of N.
  • The number of 0s in s is a multiple of M.

A good string is called perfect if it doesn't contain shorter good (contiguous) substrings. For example, if N = 3 and M = 2, then strings 111, 00 and 10101 are perfect, but 0000 and 11001 are not.
One can show that for any N, M the number of perfect strings is finite. Find this number modulo 998\,244\,353.

Input

Input is given from Standard Input in the following format:
N M

Output

Print the answer.

Constraints

  • $1 \leq N, M \leq 40$
  • All values in the input are integers.

Sample Input 1

2 2

Sample Output 1

4

The perfect strings are 00, 0101, 1010, 11.

Sample Input 2

3 2

Sample Output 2

7

The perfect strings are 00, 01011, 01101, 10101, 10110, 11010, 111.

Sample Input 3

23 35

Sample Output 3

212685109

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2
样例输出
4