#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int findhum(int* inpa, int* inpb, int k, int n, int st)
{
int num = k%n;
if(num == 0)
num = k;
int i;
int c = 1;
for(i = inpa[st];; i = inpa[i])
if(c++ == num)
return i;
}
void killi(int *inpa, int* inpb, int i)
{
inpa[inpb[i]] = inpa[i];
inpb[inpa[i]] = inpb[i];
return ;
}
int main ()
{
int n, k, m;
while(scanf("%d %d %d", &n, &k, &m) == 3 && n && k && m)
{
if(n == 1){
printf(" 1\n");
continue;
}
int a = n, b = 1;
int la [30];
int lb [30];
la[1] = 2;
lb[1] = n;
for(int i = 2; i < n; i++)
{
la[i] = i + 1;
lb[i] = i - 1;
}
la[n] = 1;
lb[n] = n-1 ;
int is_first = 1;
while(n)
{
if(is_first)
is_first = 0;
else
printf(",");
a = findhum(la, lb, k, n, a);
b = findhum(lb, la, m, n, b);
if(a == b)
{
printf("% 3d", a);
killi(la, lb, a);
n--;
}
else
{
printf("% 3d% 3d", a, b);
killi(la, lb, a);
if(la[a] == b){
la[a] = la[b];
lb[b] = lb[a];
}
if(lb[a] == b){
lb[a] = lb[b];
la[b] = la[b];
}
killi(lb, la, b);
n -= 2;
}
//printf("\n=%d %d=\n", la[a], lb[b]);
}
printf("\n");
}
return 0;
}
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int findhum(int* inpa, int* inpb, int k, int n, int st)
{
int num = k%n;
if(num == 0)
num = k;
int i;
int c = 1;
for(i = inpa[st];; i = inpa[i])
if(c++ == num)
return i;
}
void killi(int *inpa, int* inpb, int i)
{
inpa[inpb[i]] = inpa[i];
inpb[inpa[i]] = inpb[i];
return ;
}
int main ()
{
int n, k, m;
while(scanf("%d %d %d", &n, &k, &m) == 3 && n && k && m)
{
if(n == 1){
printf(" 1\n");
continue;
}
int a = n, b = 1;
int la [30];
int lb [30];
la[1] = 2;
lb[1] = n;
for(int i = 2; i < n; i++)
{
la[i] = i + 1;
lb[i] = i - 1;
}
la[n] = 1;
lb[n] = n-1 ;
int is_first = 1;
while(n)
{
if(is_first)
is_first = 0;
else
printf(",");
a = findhum(la, lb, k, n, a);
b = findhum(lb, la, m, n, b);
if(a == b)
{
printf("% 3d", a);
killi(la, lb, a);
n--;
}
else
{
printf("% 3d% 3d", a, b);
killi(la, lb, a);
if(la[a] == b){
la[a] = la[b];
lb[b] = lb[a];
}
if(lb[a] == b){
lb[a] = lb[b];
la[b] = la[b];
}
killi(lb, la, b);
n -= 2;
}
//printf("\n=%d %d=\n", la[a], lb[b]);
}
printf("\n");
}
return 0;
}