#include <bits/stdc++.h>
#define ll long long
#define fr first
#define endl "\n"
#define sc second
#define sz(x) (int) x.size()
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;
using pii = pair<ll, ll>;
using tii = tuple<ll, ll, ll>;
string printBin(ll m) { string a = ""; for(int i=63; i>=0; i--) { if(m & (1<<i)) {a += '1';} else {a += '0';} } return a; }

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;

    while(cin >> n) {
        if(n == 0) break;

        queue<int> q;
        vector<int> ans;

        for(int i=1; i<=n; i++) q.push(i);

        while(sz(q) >= 2) {
            auto ai = q.front();
            q.pop();
            auto aj = q.front();
            q.pop();

            q.push(aj);

            ans.pb(ai);
        }

        cout << "Discarded cards: ";
        int c = 0;

        for(auto ai : ans) {
            if(c > 0) cout << ", ";
            cout << ai;
            c++;
        }
        cout << endl;
        cout << "Remaining card: " << q.front() << endl;
    }
}