#include<stdio.h>
int main(void){
    int n, m, i, count, M, P[100];
    while ( scanf("%d %d", &n, &m) != EOF ) {
        count = 1;
        for ( i = 1; i < n; i++ ) P[i] = 0;
        i = 1;
        while (count <= n) {
            M = m;
            while ( M-- ) {
                while ( P[i] != 0 || i > n) {
                    i++;
                    if ( i > n ) i = 1;
                }
                i++;
            } 
            i--;
            printf("%d\n", i);
            P[i] = count++;
            i++;
        }
        printf("%d\n", i);
    }
    return 0;
}