#P9531. Zju1961 Let it Bead

    ID: 6116 传统题 1000ms 256MiB 尝试: 1 已通过: 1 难度: 6 上传者: 标签>CF1900提高Burnside 引理按不动点计数置换循环分解欧几里得算法快速幂

Zju1961 Let it Bead

Description

给定颜色种数和环上的珠子总数,问有多少种染色方案(通过旋转和翻转相同的算同一种)。

Format

Input

Every line of the input defines a test case and contains two integers: the number of available colors c followed by the length of the bracelets s. Input is terminated by c = s = 0. Otherwise, both are positive, and, due to technical difficulties in the bracelet-fabrication-machine, cs <= 32, i.e. their product does not exceed 32.

Output

For each test case output on a single line the number of unique bracelets. The figure below shows the 8 different bracelets that can be made with 2 colors and 5 beads.

Samples

1 1
2 1
2 2
5 1
2 5
2 6
6 2
0 0
1
2
3
5
8
13
21