Bug in my </> | Bowling Strategy COOK122B

Can anyone find the bug in my code of this problem?

#include <iostream>
using namespace std;

void solve(){
    int n, k, l; cin>>n>>k>>l;
    int r = n%k, q = n/k;
    if(((!r && q <= l) || (q+1 <= l)) && (k != 1)){
        int cnt = 1;
        for(int i=0;i<n;i++){
            if(cnt == k+1) cnt = 1;
            cout<<cnt++<<' ';
        }
    }else cout<<-1;
}
int main(){
    sync();
    int tc; cin>>tc;
    while(tc--){
        solve();
        cout<<endl;
    }
    return 0;
}
while(boolean/condition)

Not take integer like this while(integer/double....)

Didn’t get the point @himanshukr