#include <iostream>
#include <cstdio>
#include <queue>
#include <string>

using namespace std;

int main(){
    int n, p, m;
    queue<int> q;
    while(cin >> n >> p >> m){
        if(n == 0 && p == 0 && m == 0) return 0;
        for(int i = 1; i < n+1; i++){
            q.push(i);
        }
        int tmp;
        for(int j = 1; j < p; j++){
            tmp = q.front();
            q.push(tmp);
            q.pop();
        }


        int t = 1;
        while(!q.empty()){
            if(t % m == 0){
                if(t == m){
                    printf("%d", q.front());
                }else{
                    printf(",%d", q.front());
                }
                q.pop();
            }else{
                tmp = q.front();
                q.push(tmp);
                q.pop();
            }
            t++;
//            printf("\n");
//            for(int i = 1; i < n+1; i++){
//                printf("%d ", q.front());
//                tmp = q.front();
//                q.push(tmp);
//                q.pop();
//            }

        }
        printf("\n");

    }

    return 0;
}

/*
提交网站 
https://vjudge.net/problem/OpenJ_Bailian-3254
*/