#include<stdio.h>
int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int x;
    int count;
    count=0;
    x=n;
    do{
        n=n-k;
        if(n<1){
            n=n*(-1);
        }
        if(n<x){
            x=n;
        }
        printf("%d %d\n",n,x);
        count+=1;
        if(count>2&&n==x) break;
    }
    while(n>=x);
    printf("%d\n",x);
    return 0;
}