#include <stdio.h>
#include <stdlib.h>

int main(){
    long n,k;
    scanf("%ld %ld",&n,&k);
    printf("%ld %ld\n",n,k);
    long past=n+1,now=n;
    while(now<past){
        past=now;
        now=labs(now-k);
    }
    printf("%ld\n",past);
}
