This page is still under construction.

Parts of this page are still being built. What you see may change.

Blocks 3

Time limit1sMemory limit256 MB

Summary
Count the tilings of an N by M rectangle using blocks of size k by N for any k, allowing 90-degree rotation, modulo 1999.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, Math, Matrix
Solved
No attempts yet

Problem

You fill a rectangle completely with blocks. For each of the 1×N1 \times N, 2×N2 \times N, ..., N×NN \times N blocks you have an unlimited supply.

Fill a rectangle of height NN and width MM with these blocks. Blocks must not overlap and must not stick out of the rectangle. A block may be rotated by 90 degrees, so a k×Nk \times N block can be placed as kk rows by NN columns, or as NN rows by kk columns.

Count the ways to fill the rectangle and print that count modulo 1999. Two ways are different when at least one cell is covered by a block sitting in a different place.

Input

The first line contains NN and MM, separated by a space. (1≤N≤1031 \le N \le 10^3, 1≤M≤1061 \le M \le 10^6)

Output

Print the number of ways to fill the rectangle, modulo 1999.

Examples4

  1. Example 1

    Input
    2 12
    
    Expected output
    732
    
  2. Example 2

    Input
    1 1
    
    Expected output
    1
    
  3. Example 3

    Input
    3 3
    
    Expected output
    7
    
  4. Example 4

    Input
    5 5
    
    Expected output
    31