#K50637. Equal Height Grid Initialization

    ID: 28909 Type: Default 1000ms 256MiB

Equal Height Grid Initialization

Equal Height Grid Initialization

You are given a grid of size n x m. Each cell of the grid should be initialized with an integer chosen from the range [L, R] (inclusive). There exists a set of allowed operations that can be performed on the grid, and using these operations, it must be possible to make all the cells in the grid have the same height.

Your task is to determine the number of ways to initialize the grid so that it is possible to achieve an equal height across all cells by applying the allowed operations.

Observation: It turns out that regardless of the dimensions n and m, the number of valid initializations is determined solely by the number of distinct integers available, which is given by the formula:

result=(RL+1)mod106result = (R - L + 1) \mod 10^6

Compute and output this value.

inputFormat

The input consists of a single line containing four space-separated integers: n, m, L, and R.

outputFormat

Output a single integer representing the number of ways to initialize the grid, computed as (R - L + 1) modulo 10^6.

## sample
2 2 1 3
3

</p>