public class Game {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = 0, m = 0;
while (scan.hasNext()) {
n = scan.nextInt();
m = scan.nextInt();
int[] peoples = new int[n];
for (int i = 0; i < peoples.length; i++) {
peoples[i] = 0;
}
int[] fails = new int[n];
int c = 0;
int step = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (peoples[step] == 0) {
step++;
if (step >= n) {
step = 0;
}
} else {
j--;
step++;
if (step >= n) {
step = 0;
}
}
}
int tempor = step - 1;
if (tempor < 0) {
tempor = n - 1;
}
fails[c++] = tempor + 1;
peoples[tempor] = 1;
}
for (int i = 0; i < fails.length - 1; i++) {
System.out.print(fails[i] + "\t");
}
System.out.println();
System.out.print(fails[n - 1]);
}
}
}