#include"stdio.h"#include"iostream"#include"algorithm"#include"string.h"usingnamespacestd;
int n, k, m;
int le;
int a[21];
void solve()
{
int i = 0, j = n + 1;
while (le)//还有剩下的人时
{
int acnt = 0, bcnt = 0;
while (acnt != k)//A是否数了k个
{
i++;
if (i > n)i = 1;
if (a[i] != 0)acnt++;
//printf("i=%d,acnt=%d\n", i, acnt);
}
while (bcnt != m)//B是否数了m个
{
j--;
if (j < 1)j = n;
if (a[j] != 0)bcnt++;
//printf("j=%d,bcnt=%d\n", j, bcnt);
}
if (le != n)printf(",");
printf("%3d", a[i]);
le--;
if (i != j)
{
printf("%3d", a[j]);
le--;
}
if (!le)printf("\n");
a[i] = a[j] = 0;
}
}
void init()
{
for (int i = 1; i <= n; ++i)
a[i] = i;
le = n;
}
int main()
{
while (cin >> n >> k >> m && n != 0)
{
init();
solve();
}
return0;
}