#agc061f. [agc061_f]Perfect Strings

[agc061_f]Perfect Strings

Problem Statement

There are positive integers NN and MM.

A binary string ss is called good if all of the followings are satisfied:

  • ss is non-empty.
  • The number of 1s in ss is a multiple of NN.
  • The number of 0s in ss is a multiple of MM.

A good string is called perfect if it doesn't contain shorter good (contiguous) substrings. For example, if N=3N = 3 and M=2M = 2, then strings 111, 00 and 10101 are perfect, but 0000 and 11001 are not.

One can show that for any N,MN, M the number of perfect strings is finite. Find this number modulo 998,244,353998\\,244\\,353.

Constraints

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

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the answer.


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