#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Matrix
//-------------------------------------------------
template<typename T>
class Matrix
{
private:
    using V = ::std::vector<T>;
    using M = ::std::vector<V>;
    M dat;
    int h,w;
public:
    Matrix(int h_, int w_):h(h_),w(w_){
        dat.resize(h,V(w));
    }
    Matrix(const M &mat){
        h = mat.size();
        w = mat[0].size();
        dat.resize(h,V(w));
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]=mat[i][j];
    }
    Matrix(const Matrix &m){
        h = m.h; w = m.w;
        dat.resize(h,V(w));
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]=m.dat[i][j];
    }
    static Matrix getI(int n){
        Matrix ret(n,n);
        for(int i=0;i<n;i++) ret[i][i] = 1;
        return ret;
    }
    Matrix& operator+=(const Matrix &m){
        assert(m.h==h && m.w==w);
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]+=m.dat[i][j];
        return *this;
    }
    Matrix& operator-=(const Matrix &m){
        assert(m.h==h && m.w==w);
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]-=m.dat[i][j];
        return *this;
    }
    Matrix& operator*=(const Matrix &m){
        assert(m.h==w);
        M ret(h, V(m.w));
        for(int i=0; i<h; i++)
            for(int j=0; j<m.w; j++)
                for(int k=0; k<w; k++)
                    ret[i][j]+=dat[i][k]*m.dat[k][j];
        dat.swap(ret);
        return *this;
    }
    Matrix& operator*=(T c){
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]*=c;
        return *this;
    }
    Matrix& operator^=(::std::uint_fast64_t t){
        assert(h==w);
        Matrix ret = Matrix::getI(h);
        Matrix m(*this);
        while(t){
            if (t&1) ret*=m;
            m*=m;
            t>>=1;
        }
        dat.swap(ret.dat);
        return *this;
    }
    Matrix operator+(const Matrix &m) const {return Matrix(*this)+=m;}
    Matrix operator-(const Matrix &m) const {return Matrix(*this)-=m;}
    Matrix operator*(const Matrix &m) const {return Matrix(*this)*=m;}
    Matrix operator*(T c) const {return Matrix(*this)*=c;}
    Matrix operator^(::std::uint_fast64_t t) const {return Matrix(*this)^=t;}
    Matrix operator-() const {return Matrix(*this)*=-1;}
    V& operator[](int h){return dat[h];}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L; cin>>L;
    int n=1,m;
    using edge = tuple<int,int,int>;
    vector<edge> es;
    stack<int> st;
    while(L){
        st.push(L);
        if (L&1) st.push(L-1);
        L>>=1;
    }
    st.pop();
    int now = st.top(); st.pop();
    while(st.size()){
        int t = st.top(); st.pop();
        if (now*2==t){
            for(auto &e:es){
                get<2>(e) *= 2;
            }
            es.emplace_back(n, n+1, 0);
            es.emplace_back(n, n+1, 1);
            n++;
        }else{
            es.emplace_back(1, n, now);
        }
        now = t;
    }
    m = es.size();
    cout<<n<<" "<<m<<"\n";
    for(auto e:es){
        int from,to,c;
        tie(from,to,c) = e;
        cout<<from<<" "<<to<<" "<<c<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256