#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
while(cin>>t&&t!=0)
{
queue<int>cards;
for(int i=1;i<=t;i++)
cards.push(i);
cout<<"Discarded cards: ";
if(t==1)
cout<<endl;
while(t>2)
{
int temp=cards.front();
cards.pop();
cout<<temp<<", ";
temp=cards.front();
cards.pop();
cards.push(temp);
t--;
}
if(t==2)
{
int temp=cards.front();
cout<<temp<<endl;
cards.pop();
t--;
}
if(t==1)
{
cout<<"Remaining card: ";
cout<<cards.front()<<endl;
}
}
}