Two contries A and B have decided to make a meeting to get acquainted with each other. n ambassadors from A and B will attend the meeting in total.

A round table is prepared for in the meeting. The ambassadors are getting seated at the round table, but they have agreed that more than k ambassadors from the same country does not sit down at the round table in a row for deeper exchange.

Your task is to write a program that reports the number of possible arrangements when rotations are not counted. Your program should report the number modulo M = 1000003.

Let us provide an example. Suppose n = 4 and k = 2. When rotations are counted as different arrangements, the following six arrangements are possible.


AABB
ABBA
BBAA
BAAB
ABAB
BABA


However, when rotations are regarded as same, the following two arrangements are possible.


AABB
ABAB


Therefore the program should report 2.



Input

The input consists of multiple datasets. Each dataset consists of two integers n (1 ≤ n ≤ 1000) and k (1 ≤ k ≤ 1000) in one line.

It does not always hold k < n. This means the program should consider cases in which the ambassadors from only one country attend the meeting.

The last dataset is followed by a line containing two zeros. This line is not a part of any dataset and should not be processed.

Output

For each dataset, print the number of possible arrangements modulo M = 1000003 in one line.

Example

Input

3 1
3 2
3 3
4 2
10 5
1000 500
0 0


Output

0
2
4
2
90
570682
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

const int mod = 1000003;
const int MAX = 1001;

int dp1A[MAX][MAX];
int dp1B[MAX][MAX];
int dp2[MAX];
int dp3[MAX];

int main(){
  int n, k;

  while(scanf("%d%d", &n, &k), n + k){
    int asum = 1;
    int bsum = 0;
    int ans = 0;

    if(k >= n){
      k = n - 1;
      ans = 2;
    }

    memset(dp1A, 0, sizeof(dp1A));
    memset(dp1B, 0, sizeof(dp1B));
    memset(dp2, 0, sizeof(dp2));
    memset(dp3, 0, sizeof(dp3));

    dp1A[1][1] = 1;
    dp1B[1][1] = 0;
    
    for(int i = 2; i <= n; i++){
      dp1A[i][1] = bsum;
      dp1B[i][1] = asum;

      asum = dp1A[i][1];
      bsum = dp1B[i][1];

      for(int j = 2; j <= min(k, i); j++){
	asum += (dp1A[i][j] = dp1A[i-1][j-1]); asum %= mod;
	bsum += (dp1B[i][j] = dp1B[i-1][j-1]); bsum %= mod;
      }
    }

    // puts("dp1A:"); for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++) printf("%d ", dp1A[i][j]); puts(""); }
    // puts("dp1B:"); for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++) printf("%d ", dp1B[i][j]); puts(""); }

    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= k; j++){
	dp2[i] += dp1B[i][j];
	dp2[i] %= mod;
      }

    for(int i = 1; i <= n; i++)
      for(int j = 1; j < k; j++){
	dp1B[i][j + 1] += dp1B[i][j];
	dp1B[i][j + 1] %= mod;
      }

    for(int i = 1; i <= n; i++)
      for(int p = 1; p <= min(i, k); p++){
	dp2[i] += dp1B[i - p][k - p];
	dp2[i] %= mod;
      }

    /*
    puts("dp2:");
    for(int i = 1; i <= n; i++)
      printf("%d ", dp2[i]);
    puts("");
    */

    for(int i = 1; i <= n; i++){
      dp3[i] = (2 * dp2[i]) % mod;
      for(int j = 2; j < i; j++) if(i % j == 0){
	dp3[i] -= dp3[j];
	dp3[i] = (dp3[i] + mod) % mod;
      }
    }

    /* 
    puts("dp3:");
    for(int i = 1; i <= n; i++)
      printf("%d ", dp3[i]);
    puts("");
    */

    for(int i = 2; i <= n; i++){
      if(n % i == 0){
	int tmp = 0;
	for(int j = 0; j < mod; j++){
	  if(tmp == 1){
	    tmp = j; break;
	  }
	  tmp += i; tmp %= mod;
	}

	ans = (ans + ((long long)dp3[i] * tmp) % mod) % mod;
      }
    }

    printf("%d\n", ans, n, k);
  }
}