/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
public static void main
(String[] args
) { calc(5, 2);
}
public static void calc(int n, int k) {
for (int i = 1; i <= k; i++) {
process(i, n, k);
}
}
public static void process(int startWith, int n, int k) {
for (int i = 1; i <= k; i++) {
processNext(startWith, i, n, k);
}
}
public static void processNext(int startWith, int nextWith, int n, int k) {
int sum = startWith;
System.
out.
print(startWith
+ " "); while (sum < n) {
int step = nextWith;
if (sum + step > n) {
step = (sum + step) % n;
}
sum += step;
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUgewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewoJCWNhbGMoNSwgMik7Cgl9CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBjYWxjKGludCBuLCBpbnQgaykgewoJCWZvciAoaW50IGkgPSAxOyBpIDw9IGs7IGkrKykgewoJCQlwcm9jZXNzKGksIG4sIGspOwoJCX0KCX0KCQoJcHVibGljIHN0YXRpYyB2b2lkIHByb2Nlc3MoaW50IHN0YXJ0V2l0aCwgaW50IG4sIGludCBrKSB7CgkJZm9yIChpbnQgaSA9IDE7IGkgPD0gazsgaSsrKSB7CgkJCXByb2Nlc3NOZXh0KHN0YXJ0V2l0aCwgaSwgbiwgayk7CgkJfQoJfQoJCglwdWJsaWMgc3RhdGljIHZvaWQgcHJvY2Vzc05leHQoaW50IHN0YXJ0V2l0aCwgaW50IG5leHRXaXRoLCBpbnQgbiwgaW50IGspIHsKCQlpbnQgc3VtID0gc3RhcnRXaXRoOwoJCVN5c3RlbS5vdXQucHJpbnQoc3RhcnRXaXRoICsgIiAiKTsKCQl3aGlsZSAoc3VtIDwgbikgewoJCQlpbnQgc3RlcCA9IG5leHRXaXRoOwoJCQlpZiAoc3VtICsgc3RlcCA+IG4pIHsKCQkJCXN0ZXAgPSAoc3VtICsgc3RlcCkgJSBuOwoJCQl9CgkJCVN5c3RlbS5vdXQucHJpbnQoc3RlcCArICIgIik7CgkJCXN1bSArPSBzdGVwOwoJCX0KCQlTeXN0ZW0ub3V0LnByaW50bG4oKTsKCX0KfQ==