//package CodeForces;

import java.util.Scanner;

public class SolveTheMaze {

	static int check(char ch[][],int i,int j,boolean vis[][],int dp[][],int n,int m)
	{
		if(i==n&&j==m)
		{
			if(ch[i][j]=='#')
			{
				return -1;
			}
			return 1;
		}
		if(i<0||j<0||i>n||j>m)
		{
			return -1;
		}
		if(vis[i][j])
		{
			return -1;
		}
		vis[i][j]=true;
		if(dp[i][j]!=0)
		{
			return dp[i][j];
		}
		int xx[]= {1,0,0,-1};
		int yy[]= {0,1,-1,0};
		dp[i][j]=-1;
		for(int k=0;k<xx.length;k++)
		{
			int ans=check(ch,i+xx[k],j+yy[k],vis,dp,n,m);
			dp[i][j]=Math.max(dp[i][j],ans);
		}
		return dp[i][j];
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		while(t>0)
		{
			int n=s.nextInt();
			int m=s.nextInt();
			char ch[][]=new char[n][m];
			for(int i=0;i<n;i++)
			{
				String str=s.next();
				for(int j=0;j<str.length();j++)
				{
					ch[i][j]=str.charAt(j);
				}
			}
			boolean done=true;
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					if(ch[i][j]=='B')
					{
						if(i-1>=0&&ch[i-1][j]=='G')
						{
							done=false;
							break;
						}
						else if(i-1>=0)
						{
							ch[i-1][j]='#';
						}
						if(j-1>=0&&ch[i][j-1]=='G')
						{
							done=false;
							break;
						}
						else if(j-1>=0)
						{
							ch[i][j-1]='#';
						}
						if(i+1<n&&ch[i+1][j]=='G')
						{
							done=false;
							break;
						}
						else if(i+1<n)
						{
							ch[i+1][j]='#';
						}
						if(j+1<m&&ch[i][j+1]=='G')
						{
							done=false;
							break;
						}
						else if(j+1<m)
						{
							ch[i][j+1]='#';
						}
					}
				}
			}

			if(done)
			{
				int dp[][]=new int[n][m];
				for(int i=0;i<n;i++)
				{
					for(int j=0;j<m;j++)
					{
						if(ch[i][j]=='G')
						{
							boolean vis[][]=new boolean[n][m];
							int  check=check(ch,i,j,vis,dp,n-1,m-1);
							if(check==-1)
							{
								done=false;
								break;
							}
						}
					}
				}

				if(done)
				{
					System.out.println("Yes");
				}
				else
				{
					System.out.println("No");
				}
			}
			else
			{
				System.out.println("No");
			}
		}

	}

}


//package CodeForces;

import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;

public class SolveTheMaze {

	static class node
	{
		int x;
		int y;
		node(int a,int b)
		{
			this.x=a;
			this.y=b;
		}
	}

	static int solve(char ch[][])
	{
		Queue<node> q=new LinkedList<node>();
		int x=ch.length-1;int y=ch[0].length-1;
		node root=new node(x,y);
		q.add(root);int count=0;
		boolean vis[][]=new boolean[ch.length][ch[0].length];
		vis[ch.length-1][ch[0].length-1]=true;
		while(!q.isEmpty())
		{
			node temp=q.remove();
			if(ch[temp.x][temp.y]=='B')
			{
				return -1;
			}
			if(ch[temp.x][temp.y]=='G')
			{
				count++;
			}
			if(temp.x-1>=0&&ch[temp.x-1][temp.y]!='#'&&ch[temp.x-1][temp.y]!='B'&&!vis[temp.x-1][temp.y])
			{
				node newnode=new node(temp.x-1,temp.y);
				vis[temp.x-1][temp.y]=true;
				q.add(newnode);
			}
			if(temp.y-1>=0&&ch[temp.x][temp.y-1]!='#'&&ch[temp.x][temp.y-1]!='B'&&!vis[temp.x][temp.y-1])
			{
				node newnode=new node(temp.x,temp.y-1);
				vis[temp.x][temp.y-1]=true;
				q.add(newnode);
			}
			if(temp.y+1<ch[0].length&&ch[temp.x][temp.y+1]!='#'&&ch[temp.x][temp.y+1]!='B'&&!vis[temp.x][temp.y+1])
			{
				node newnode=new node(temp.x,temp.y+1);
				vis[temp.x][temp.y+1]=true;
				q.add(newnode);
			}
			if(temp.x+1<ch.length&&ch[temp.x+1][temp.y]!='#'&&ch[temp.x+1][temp.y]!='B'&&!vis[temp.x+1][temp.y])
			{
				node newnode=new node(temp.x+1,temp.y);
				vis[temp.x+1][temp.y]=true;
				q.add(newnode);
			}
		}
		return count;
	}

	static int check(char ch[][],int i,int j,boolean vis[][],int dp[][],int n,int m)
	{
		if(i==n&&j==m)
		{
			if(ch[i][j]=='#')
			{
				return -1;
			}
			return 1;
		}
		if(i<0||j<0||i>n||j>m||ch[i][j]=='#')
		{
			return -1;
		}
		if(vis[i][j])
		{
			return -1;
		}
		vis[i][j]=true;
		if(dp[i][j]!=0)
		{
			return dp[i][j];
		}
		int xx[]= {1,0,0,-1};
		int yy[]= {0,1,-1,0};
		dp[i][j]=-1;
		for(int k=0;k<xx.length;k++)
		{
			int ans=check(ch,i+xx[k],j+yy[k],vis,dp,n,m);
			dp[i][j]=Math.max(dp[i][j],ans);
		}
		return dp[i][j];
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		while(t>0)
		{
			int n=s.nextInt();
			int m=s.nextInt();
			int g=0;
			char ch[][]=new char[n][m];
			for(int i=0;i<n;i++)
			{
				String str=s.next();
				for(int j=0;j<str.length();j++)
				{
					ch[i][j]=str.charAt(j);
					if(ch[i][j]=='G')
					{
						g++;
					}
				}
			}
			boolean done=true;
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					if(ch[i][j]=='B')
					{
						if(i-1>=0&&ch[i-1][j]=='G')
						{
							done=false;
							break;
						}
						else if(i-1>=0&&ch[i-1][j]=='.')
						{
							ch[i-1][j]='#';
						}
						if(j-1>=0&&ch[i][j-1]=='G')
						{
							done=false;
							break;
						}
						else if(j-1>=0&&ch[i][j-1]=='.')
						{
							ch[i][j-1]='#';
						}
						if(i+1<n&&ch[i+1][j]=='G')
						{
							done=false;
							break;
						}
						else if(i+1<n&&ch[i+1][j]=='.')
						{
							ch[i+1][j]='#';
						}
						if(j+1<m&&ch[i][j+1]=='G')
						{
							done=false;
							break;
						}
						else if(j+1<m&&ch[i][j+1]=='.')
						{
							ch[i][j+1]='#';
						}
					}
				}
			}

			if(g==0)
			{
				System.out.println("Yes");
			}
			else if(!done)
			{
				System.out.println("No");
			}
			else if(ch[n-1][m-1]!='#')
			{
				int count=solve(ch);
				//System.out.println(count);
				if(count==g)
				{
					System.out.println("Yes");
				}
				else
				{
					System.out.println("No");
				}
			}
			else
			{
				System.out.println("No");
			}

//			if(done)
//			{
//				int dp[][]=new int[n][m];
//				for(int i=0;i<n;i++)
//				{
//					for(int j=0;j<m;j++)
//					{
//						if(ch[i][j]=='G')
//						{
//							boolean vis[][]=new boolean[n][m];
//							int  check=check(ch,i,j,vis,dp,n-1,m-1);
//							if(check==-1)
//							{
//								done=false;
//								break;
//							}
//						}
//					}
//				}
//
//				if(done)
//				{
//					System.out.println("Yes");
//				}
//				else
//				{
//					System.out.println("No");
//				}
//			}
//			else
//			{
//				System.out.println("No");
//			}
			t--;
		}

	}

}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define lli                      long long int
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define pdd                      pair<double,double>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define all(v)                   v.begin(),v.end()
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define mem(array,value)         memset(array,value,sizeof array)
#define TEST_CASE                int t;scanf("%d",&t);for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define F(var,st,end)            for(int var=st;(int)var<=end;var++)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define nln                      printf("\n")
#define inf                      99999999999
#define mod                      1000000007
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define fastIO                   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define watch(x)   	            cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define maxn 200005

int main()///dekhe
{
     int k;
     cin>>k;
     cout<<"2 3\n";
      cout<<pow(2,17)+k<<" "<<k<<" "<<0;nln;
      cout<<0<<" "<<pow(2,17)+k<<" "<<k;nln;

return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define lli                      long long int
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define pdd                      pair<double,double>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define all(v)                   v.begin(),v.end()
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define mem(array,value)         memset(array,value,sizeof array)
#define TEST_CASE                int t;scanf("%d",&t);for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define F(var,st,end)            for(int var=st;(int)var<=end;var++)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define nln                      printf("\n")
#define inf                      99999999999
#define mod                      1000000007
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define fastIO                   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define watch(x)   	            cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define maxn 200005
void bin(int n){
        string s="";
    while(n){
        s+=n%2+'0';
        n/=2;
    }
    reverse(all(s));
    if(s.size()==0) {cout<<0;return;}
    cout<<s;
}

int main()///dekhe
{

       /* int n,m;//ei function ta theke 0 ase amn vabe matrix deasign korte hbe

        cin>>n>>m;
     int a[n+1][m+1];
     for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>a[i][j];
     }
     int dp[n+1][m+1];
     mem(dp,0);
     dp[0][1]=a[1][1];
     for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
                dp[i][j]=max(dp[i-1][j]&a[i][j],dp[i][j-1]&a[i][j]);
                cout<<i-1<<" "<<j<<" "<<dp[i][j]<<" "<<i<<" "<<j-1<<endl;
        }
        nln;
     }*/
     int k;
     cin>>k;
     cout<<"2 3\n";
      cout<<131072+k<<" "<<131072<<" "<<0<<endl;
      cout<<k<<" "<<131072+k<<" "<<k<<endl;
      // ei matrix theke qs onukai k asbe,,so difference is k

return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define lli                      long long int
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define pdd                      pair<double,double>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define all(v)                   v.begin(),v.end()
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define mem(array,value)         memset(array,value,sizeof array)
#define TEST_CASE                int t;scanf("%d",&t);for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define F(var,st,end)            for(int var=st;(int)var<=end;var++)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define nln                      printf("\n")
#define inf                      99999999999
#define mod                      1000000007
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define fastIO                   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define watch(x)   	            cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define maxn 200005

int main()///dekhe
{
     int k;
     cin>>k;
     cout<<"2 3\n";
      cout<<pow(2,17)+k<<" "<<k<<" "<<0;nln;
      cout<<k<<" "<<pow(2,17)+k<<" "<<k;nln;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()///dekhe
{
     int k;
     cin>>k;
     cout<<"2 3\n";
      cout<<131072+k<<" "<<131072<<" "<<0<<endl;
      cout<<k<<" "<<131072+k<<" "<<k<<endl;

return 0;
}


#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip pair<int, pair<int, int> >
#define viv vector<vector<int> >
#define vip vector<pair<int,int> >
#define vi vector<int>
#define mii  map<int, int>
#define li list<int>
#define qu queue<int>
#define set set<int>
#define ps(x,y) fixed<<setprecision(y)<<x
using namespace std;
// author :: Anurag Anand.
//std::cout << std::setprecision(9) << f << '\n';
using namespace std;
int z=1e9+7;
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a);
			b--;
		}
		else
		{
			a=(a*a);
			b=b>>1;
		}
	}
	return res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    int k1=0, k2=0;
    string s;
    for(int i=0;i<18;i++){
        if(k&(1<<i))s+='1';
        else s+='0';
    }
    int p=0;
    for(int i=17;i>=0;i--){
        if(s[i]=='1'){
            p= i;break;
        }
    }
    for(int i=0;i<=p+1;i++){
        if(s[i]=='0') k1+=power(2, i);
        k2+= power(2, i);
    }
    cout<<"3"<<" "<<"3\n";
    int ar[3][3];
    ar[0][1]=k;ar[0][2]=k;ar[0][0]=k2;
    ar[1][0]=k1;ar[1][1]=k1;ar[1][2]=k2;
    ar[2][0]=k1;ar[2][1]=k1;ar[2][2]=k;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cout<<ar[i][j]<<" ";
        cout<<"\n";
    }
}


#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip pair<int, pair<int, int> >
#define viv vector<vector<int> >
#define vip vector<pair<int,int> >
#define vi vector<int>
#define mii  map<int, int>
#define li list<int>
#define qu queue<int>
#define set set<int>
#define ps(x,y) fixed<<setprecision(y)<<x
using namespace std;
// author :: Anurag Anand.
//std::cout << std::setprecision(9) << f << '\n';
using namespace std;
int z=1e9+7;
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a);
			b--;
		}
		else
		{
			a=(a*a);
			b=b>>1;
		}
	}
	return res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    int k1, k2;
    string s;
    for(int i=0;i<18;i++){
        if(k&(1<<i))s+='1';
        else s+='0';
    }
    int p=0;
    for(int i=17;i>=0;i--){
        if(s[i]=='1'){
            p= i;break;
        }
    }
    for(int i=0;i<=p+1;i++){
        if(s[i]=='0') k1+=power(2, i);
        k2+= power(2, i);
    }
    cout<<"3"<<" "<<"3\n";
    int ar[3][3];
    ar[0][1]=k;ar[0][2]=k;ar[0][0]=k2;
    ar[1][0]=k1;ar[1][1]=k1;ar[1][2]=k2;
    ar[2][0]=k1;ar[2][1]=k1;ar[2][2]=k;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cout<<ar[i][j]<<" ";
        cout<<"\n";
    }
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip vector<pair<int, pair<int, int> > >
#define viv vector<vector<int> >
#define vip vector<pair<int,int> >
#define set set<int>
#define vi   vector<int>
#define vi1 vector<int>
#define qu queue<int>
#define mii  map<int, int>
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
// author :: Anurag Anand.
int z= 1000000009;
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a);
			b--;
		}
		else
		{
			a=(a*a);
			b=b>>1;
		}
	}
	return res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    int off=0;
    for(int i=0;i<32;i++){
        if(!(k&(1<<i))){
            off= i;
            break;
        }
    }
    int p= (1<<off), q= (p|k);
    cout<<"3"<<" "<<"3\n";
    int ar[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            ar[i][j]=k;
        }
    }
    ar[0][0]=q;ar[0][1]=q;ar[0][2]=0;ar[1][1]=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cout<<ar[i][j]<<" ";
        }
        cout<<"\n";
    }
}


#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int  long long
#define double long double
#define pb   push_back
#define mp   make_pair
#define pii  pair<int,int>
#define pip pair<int, pair<int, int> >
#define viv vector<vector<int> >
#define vip vector<pair<int,int> >
#define vi vector<int>
#define mii  map<int, int>
#define li list<int>
#define qu queue<int>
#define set set<int>
#define ps(x,y) fixed<<setprecision(y)<<x
using namespace std;
// author :: Anurag Anand.
//std::cout << std::setprecision(9) << f << '\n';
using namespace std;
int z=1e9+7;
int power(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res=(res*a);
			b--;
		}
		else
		{
			a=(a*a);
			b=b>>1;
		}
	}
	return res;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    int k1, k2;
    string s;
    for(int i=0;i<18;i++){
        if(k&(1<<i))s+='1';
        else s+='0';
    }
    int p=0;
    for(int i=17;i>=0;i--){
        if(s[i]=='1'){
            p= i;break;
        }
    }
    for(int i=0;i<=p+1;i++){
        if(s[i]=='0') k1+=power(2, i);
        k2+= power(2, i);
    }
    cout<<"3"<<" "<<"3\n";
    int ar[3][3];
    ar[0][1]=k;ar[0][2]=k;ar[0][0]=k2;
    ar[1][0]=k1;ar[1][1]=k1;ar[1][2]=k2;
    ar[2][0]=k1;ar[2][1]=k1;ar[2][2]=k;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cout<<ar[i][j]<<" ";
        }
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k;
	cout<<3<<" "<<3<<endl;
	ll p=262144;
	cout<<p<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<p+k<<" "<<k<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll a[5][5],dp[5][5];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k;
	cout<<3<<" "<<3<<endl;
	ll p=262144;
	cout<<p+k<<" "<<p+k<<" "<<0<<endl;
	cout<<p+k<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<p+k<<" "<<k<<endl;

	// a[1][1]=p+k;
	// a[1][2]=p+k;
	// a[1][3]=0;
	// a[2][1]=p+k;
	// a[2][2]=k;
	// a[2][3]=0;
	// a[3][1]=p;
	// a[3][2]=p+k;
	// a[3][3]=k;

	// n=3,m=3;
	// for(i=1;i<=n;i++)
	// {
	// 	for(j=1;j<=m;j++)
	// 	{
	// 		x=-1,y=-1;
	// 		if(i>1)
	// 			x=a[i][j]&dp[i-1][j];
	// 		if(j>1)
	// 			y=a[i][j]&dp[i][j-1];

	// 		if(x==-1 && y==-1)
	// 			dp[i][j]=a[i][j];
	// 		else
	// 			dp[i][j]=max(x,y);
	// 	}
	// }

	// for(i=1;i<=3;i++)
	// {
	// 	for(j=1;j<=3;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k;
	cout<<3<<" "<<3<<endl;
	ll p=262144;
	cout<<p<<" "<<p+k<<" "<<0<<endl;
	cout<<p<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<p+k<<" "<<k<<endl;

	// for()
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k;
	cout<<3<<" "<<3<<endl;
	ll p=262144;
	cout<<k<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<p+k<<" "<<k<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll a[5][5],dp[5][5];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k;
	cout<<3<<" "<<3<<endl;
	ll p=262144/2;
	cout<<p+k<<" "<<p+k<<" "<<0<<endl;
	cout<<p+k<<" "<<k<<" "<<0<<endl;
	cout<<p<<" "<<p+k<<" "<<k<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[105];
char s[maxx];
int main()
{
    int t,n,m,k,cnt=0;
    cin>>k;
    t=k;
    while(k)
    {
        if(k%2) a[cnt]=1;
        cnt++;
        k/=2;
    }
    cout<<3<<" "<<2<<endl;
    cout<<(1<<19-1)<<" "<<t<<endl;
    cout<<(1<<18)<<" "<<(1<<18)+t<<endl;
    cout<<0<<" "<<t<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[105];
int main()
{
    int t,n,m,k;1
    cin>>k;
    cout<<3<<" "<<2<<endl;
    cout<<((1<<19)-1)<<" "<<k<<endl;
    cout<<(1<<18)<<" "<<(1<<18)+k<<endl;
    cout<<0<<" "<<k<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[105];
int main()
{
    int t,n,m,k;
    cin>>k;
    cout<<3<<" "<<2<<endl;
    cout<<((1<<18)-1)<<" "<<k<<endl;
    cout<<(1<<17)<<" "<<(1<<17)+k<<endl;
    cout<<0<<" "<<k<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[105];
int main()
{
    int t,n,m,k;
    cin>>k;
    cout<<3<<" "<<2<<endl;
    cout<<((1<<19)-1)<<" "<<k<<endl;
    cout<<(1<<18)<<" "<<(1<<18)+k<<endl;
    cout<<0<<" "<<k<<endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxx=1e6+7;
int a[105];
char s[maxx];
int main()
{
    int t,n,m,k,cnt=0;
    cin>>k;
    t=k;
    while(k)
    {
        if(k%2) a[cnt]=1;
        cnt++;
        k/=2;
    }
    cout<<3<<" "<<2<<endl;
    cout<<(1<<30-1)<<" "<<t<<endl;
    cout<<(1<<28)<<" "<<(1<<28)+t<<endl;
    cout<<0<<" "<<t<<endl;
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,i=0,j,l;
    cin>>k;
    if(k==0)
    {
        cout<<1<<" "<<1<<endl;
        cout<<1; return 0;
    }
    cout<<3<<" "<<3<<endl;
    while(k>>i) i++; i=(1<<i);
    for(j=1;j<=3;j++)
    {
        for(l=1;l<=3;l++)
        {
            if((j==1&&l==3)||(j==3&&l==3)) cout<<k<<" ";
            else if(j==1||l==3) cout<<i+k<<" ";
            else cout<<i<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,i=0,j,l;
    cin>>k;
    if(k==0)
    {
        cout<<1<<" "<<1<<endl;
        cout<<1; return 0;
    }
    cout<<4<<" "<<4<<endl;
    while(k>>i) i++;
    for(j=1;j<=4;j++)
    {
        for(l=1;l<=4;l++)
        {
            if((j==1&&l==4)||(j==4&&l==4)) cout<<k<<" ";
            else if(j==1||l==4) cout<<(1<<i)+k<<" ";
            else cout<<(1<<i)<<" ";
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    long long n, m, k, i, j, p2=1;
    std::cin >> k;
    n = m = 2;
    while (p2 <= k)
        p2 = p2 * 2;
        p2 *= 2;
        p2 --;
    int a[505][505];
    for (i=0; i<n; i++)
        for (j=0; j<m; j++)
        a[i][j] = k;
    a[0][0] = p2;
    a[0][1] = k+1;

    std::cout << n << ' ' << m << '\n';
    for (i=0; i<n; i++, std::cout << '\n')
        for (j=0; j<m; j++)
        std::cout << a[i][j] << ' ';

    return 0;
}


#include <bits/stdc++.h>

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    long long n, m, k, i, j, p2=1;
    std::cin >> k;
    n = m = 2;
    while (p2 <= k)
        p2 = p2 * 2;
        p2 *= 2;
    int a[505][505];
    for (i=0; i<n; i++)
        for (j=0; j<m; j++)
        a[i][j] = k;
    a[0][0] = p2;
    a[0][1] = k+1;

    std::cout << n << ' ' << m << '\n';
    for (i=0; i<n; i++, std::cout << '\n')
        for (j=0; j<m; j++)
        std::cout << a[i][j] << ' ';

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
int mod=998244353;
const int MAXN = 4e5+2;
//~ ll a[MAXN];

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

int t=1;  while(t--){
int k; cin>>k;
ll p=0;
if(k==0){
	cout<<"1 1\n"<<k<<endl; return 0;
}
cout<<"4 4\n";
ll d=0,tp=k;
while(tp)tp/=2,d++;
p=pow(2,d+1)-1;
int a[4][4];
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	a[i][j]=p;
}

a[0][1]=k;
a[1][0]=2*k;
a[3][3]=k;
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	cout<<a[i][j]<<" ";
	cout<<"\n";
}

}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
int mod=998244353;
const int MAXN = 4e5+2;
//~ ll a[MAXN];

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

int t=1;  while(t--){
int k; cin>>k;
ll p=0;
cout<<"4 4\n";
ll d=0,tp=k;
while(tp)tp/=2,d++;
p=pow(2,d+1)-1;
int a[4][4];
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	a[i][j]=p;
}

a[0][1]=k;
a[1][0]=2*k;
a[3][3]=k;
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	cout<<a[i][j]<<" ";
	cout<<"\n";
}

}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
int mod=998244353;
const int MAXN = 4e5+2;
//~ ll a[MAXN];

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

int t=1;  while(t--){
int k; cin>>k;
cout<<"4 4\n";
int p=(1<<18)-1;
int a[4][4];
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	a[i][j]=p;
}
a[0][1]=k;
a[1][0]=1<<17;
a[3][3]=k;
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	cout<<a[i][j]<<" ";
	cout<<"\n";
}

}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
int mod=998244353;
const int MAXN = 4e5+2;
//~ ll a[MAXN];

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

int t=1;  while(t--){
int k; cin>>k;
ll p=0;
if(k==0){
	cout<<"1 1\n"<<k<<endl; return 0;
}
ll d=0,tp=k;
while(tp)tp/=2,d++;
p=pow(2,d+1)-1;
int a[4][4];
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	a[i][j]=p;
}

a[0][1]=k;
a[1][0]=2*k;
a[3][3]=k;
for(int i=0;i<4;i++){
	for(int j=0;j<4;j++)
	cout<<a[i][j]<<" ";
	cout<<"\n";
}

}
	return 0;
}


#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define level        31
#define hell1        1000000009
using namespace std;
class disjointset
{
  ll *parent,*cnt,*rank;
  ll sze;
  public :
  disjointset(ll n) {
    rank = new ll[n + 1];
    parent = new ll[n + 1];
    cnt = new ll[n + 1];
    sze = n;
    for(ll i = 1; i <= n; i++)
    {
      parent[i] = i;
      rank[i] = 1;
      cnt[i] = 1;
    }
  }
  void join(ll a,ll b)
  {
    a = find(a);
    b = find(b);
    if(a != b)
    {
      sze--;
    }
    if(rank[a] > rank[b])
    {
      parent[b] = a;
      cnt[a] += cnt[b];
    }
    else if(rank[a] < rank[b])
    {
      parent[a] = b;
      cnt[b] += cnt[a];
    }
    else
    {
      parent[b] = a;
      cnt[a] += cnt[b];
      rank[a]++;
    }
  }
  ll find(ll a)
  {
    return a == parent[a] ? a : parent[a] = find(parent[a]);
  }
  bool check(ll a,ll b)
  {
    return find(a) == find(b);
  }
  ll getcnt(ll a)
  {
    return cnt[a];
  }
};
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll k;
    cin >> k;
    vector<vector<ll> > v1;
    ll pos = 0;
    for(ll i = 29; i >= 0; i--)
    {
      if((1 << i) & k)
      {
        pos = i + 1;
        break;
      }
    }
    cout << "3 3" << endl;
    rep(i,0,3)
    {
      vector<ll> tmp(3,0);
      v1.pb(tmp);
    }
    ll num = (1 << pos);
    ll num1 = num + k;
    v1[0][0] = num1;
    v1[1][0] = num;
    v1[2][0] = num;
    v1[2][1] = num;
    v1[0][1] = k;
    v1[0][2] = k;
    v1[1][2] = k;
    v1[2][2] = k;
    rep(i,0,3)
    {
      rep(j,0,3)
      {
        cout << v1[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define level        31
#define hell1        1000000009
using namespace std;
class disjointset
{
  ll *parent,*cnt,*rank;
  ll sze;
  public :
  disjointset(ll n) {
    rank = new ll[n + 1];
    parent = new ll[n + 1];
    cnt = new ll[n + 1];
    sze = n;
    for(ll i = 1; i <= n; i++)
    {
      parent[i] = i;
      rank[i] = 1;
      cnt[i] = 1;
    }
  }
  void join(ll a,ll b)
  {
    a = find(a);
    b = find(b);
    if(a != b)
    {
      sze--;
    }
    if(rank[a] > rank[b])
    {
      parent[b] = a;
      cnt[a] += cnt[b];
    }
    else if(rank[a] < rank[b])
    {
      parent[a] = b;
      cnt[b] += cnt[a];
    }
    else
    {
      parent[b] = a;
      cnt[a] += cnt[b];
      rank[a]++;
    }
  }
  ll find(ll a)
  {
    return a == parent[a] ? a : parent[a] = find(parent[a]);
  }
  bool check(ll a,ll b)
  {
    return find(a) == find(b);
  }
  ll getcnt(ll a)
  {
    return cnt[a];
  }
};
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll k;
    cin >> k;
    vector<vector<ll> > v1;
    ll pos = 0;
    for(ll i = 29; i >= 0; i--)
    {
      if((1 << i) & k)
      {
        pos = i + 1;
        break;
      }
    }
    cout << "2 3" << endl;
    rep(i,0,2)
    {
      vector<ll> tmp(3,0);
      v1.pb(tmp);
    }
    ll num = (1 << pos);
    ll num1 = num + k;
    v1[0][0] = num1;
    v1[1][0] = k;
    v1[0][1] = num;
    v1[1][1] = num1;
    v1[1][2] = k;
    v1[0][2] = 0;
    rep(i,0,2)
    {
      rep(j,0,3)
      {
        cout << v1[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define level        31
#define hell1        1000000009
using namespace std;
class disjointset
{
  ll *parent,*cnt,*rank;
  ll sze;
  public :
  disjointset(ll n) {
    rank = new ll[n + 1];
    parent = new ll[n + 1];
    cnt = new ll[n + 1];
    sze = n;
    for(ll i = 1; i <= n; i++)
    {
      parent[i] = i;
      rank[i] = 1;
      cnt[i] = 1;
    }
  }
  void join(ll a,ll b)
  {
    a = find(a);
    b = find(b);
    if(a != b)
    {
      sze--;
    }
    if(rank[a] > rank[b])
    {
      parent[b] = a;
      cnt[a] += cnt[b];
    }
    else if(rank[a] < rank[b])
    {
      parent[a] = b;
      cnt[b] += cnt[a];
    }
    else
    {
      parent[b] = a;
      cnt[a] += cnt[b];
      rank[a]++;
    }
  }
  ll find(ll a)
  {
    return a == parent[a] ? a : parent[a] = find(parent[a]);
  }
  bool check(ll a,ll b)
  {
    return find(a) == find(b);
  }
  ll getcnt(ll a)
  {
    return cnt[a];
  }
};
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll k;
    cin >> k;
    vector<vector<ll> > v1;
    ll pos = 0;
    for(ll i = 29; i >= 0; i--)
    {
      if((1 << i) & k)
      {
        pos = i + 1;
        break;
      }
    }
    cout << "3 3" << endl;
    rep(i,0,6)
    {
      vector<ll> tmp(6,0);
      v1.pb(tmp);
    }
    ll num = (1 << pos);
    ll num1 = num + k;
    v1[0][0] = num1;
    rep(i,0,6)
    {
      if(i == 0)
      {
        continue;
      }
      v1[i][0] = num;
    }
    rep(i,0,6)
    {
      if(i == 5)
      {
        continue;
      }
      v1[5][i] = num;
    }
    rep(i,0,6)
    {
      if(i == 0)
      {
        continue;
      }
      v1[0][i] = k;
    }
    v1[1][5] = k;
    v1[2][5] = k;
    v1[2][4] = k;
    v1[3][4] = k;
    v1[4][4] = k;
    v1[4][5] = k;
    v1[5][5] = k;
    rep(i,0,6)
    {
      rep(j,0,6)
      {
        cout << v1[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define level        31
#define hell1        1000000009
using namespace std;
class disjointset
{
  ll *parent,*cnt,*rank;
  ll sze;
  public :
  disjointset(ll n) {
    rank = new ll[n + 1];
    parent = new ll[n + 1];
    cnt = new ll[n + 1];
    sze = n;
    for(ll i = 1; i <= n; i++)
    {
      parent[i] = i;
      rank[i] = 1;
      cnt[i] = 1;
    }
  }
  void join(ll a,ll b)
  {
    a = find(a);
    b = find(b);
    if(a != b)
    {
      sze--;
    }
    if(rank[a] > rank[b])
    {
      parent[b] = a;
      cnt[a] += cnt[b];
    }
    else if(rank[a] < rank[b])
    {
      parent[a] = b;
      cnt[b] += cnt[a];
    }
    else
    {
      parent[b] = a;
      cnt[a] += cnt[b];
      rank[a]++;
    }
  }
  ll find(ll a)
  {
    return a == parent[a] ? a : parent[a] = find(parent[a]);
  }
  bool check(ll a,ll b)
  {
    return find(a) == find(b);
  }
  ll getcnt(ll a)
  {
    return cnt[a];
  }
};
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll k;
    cin >> k;
    vector<vector<ll> > v1;
    ll pos = 0;
    for(ll i = 29; i >= 0; i--)
    {
      if((1 << i) & k)
      {
        pos = i + 1;
        break;
      }
    }
    cout << "6 6" << endl;
    rep(i,0,6)
    {
      vector<ll> tmp(6,0);
      v1.pb(tmp);
    }
    ll num = (1 << pos);
    ll num1 = num + k;
    v1[0][0] = num1;
    rep(i,0,6)
    {
      if(i == 0)
      {
        continue;
      }
      v1[i][0] = num;
    }
    rep(i,0,6)
    {
      if(i == 5)
      {
        continue;
      }
      v1[5][i] = num;
    }
    rep(i,0,6)
    {
      if(i == 0)
      {
        continue;
      }
      v1[0][i] = k;
    }
    v1[1][5] = k;
    v1[2][5] = k;
    v1[2][4] = k;
    v1[3][4] = k;
    v1[4][4] = k;
    v1[4][5] = k;
    v1[5][5] = k;
    rep(i,0,6)
    {
      rep(j,0,6)
      {
        cout << v1[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
//#include<unordered_map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
#define level        31
#define hell1        1000000009
using namespace std;
class disjointset
{
  ll *parent,*cnt,*rank;
  ll sze;
  public :
  disjointset(ll n) {
    rank = new ll[n + 1];
    parent = new ll[n + 1];
    cnt = new ll[n + 1];
    sze = n;
    for(ll i = 1; i <= n; i++)
    {
      parent[i] = i;
      rank[i] = 1;
      cnt[i] = 1;
    }
  }
  void join(ll a,ll b)
  {
    a = find(a);
    b = find(b);
    if(a != b)
    {
      sze--;
    }
    if(rank[a] > rank[b])
    {
      parent[b] = a;
      cnt[a] += cnt[b];
    }
    else if(rank[a] < rank[b])
    {
      parent[a] = b;
      cnt[b] += cnt[a];
    }
    else
    {
      parent[b] = a;
      cnt[a] += cnt[b];
      rank[a]++;
    }
  }
  ll find(ll a)
  {
    return a == parent[a] ? a : parent[a] = find(parent[a]);
  }
  bool check(ll a,ll b)
  {
    return find(a) == find(b);
  }
  ll getcnt(ll a)
  {
    return cnt[a];
  }
};
int main()
{
  fast_io
  ll t;
  t = 1;
  while(t--)
  {
    ll k;
    cin >> k;
    vector<vector<ll> > v1;
    cout << "3 3" << endl;
    rep(i,0,3)
    {
      vector<ll> tmp(3,0);
      v1.pb(tmp);
    }
    ll num = (1 << 29);
    ll num1 = num + k;
    v1[0][0] = num1;
    v1[1][0] = num;
    v1[2][0] = num;
    v1[2][1] = num;
    v1[0][1] = k;
    v1[0][2] = k;
    v1[1][2] = k;
    v1[2][2] = k;
    rep(i,0,3)
    {
      rep(j,0,3)
      {
        cout << v1[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << "3 3" << endl;
	ll a[2][2], num = k, pow2 = 1;
	mem(a, 0);
	while (num > 0)
	{
		pow2 *= 2;
		num /= 2;
	}
	a[0][0] = k + pow2;
	a[0][1] = k;
	a[1][0] = pow2;
	a[1][1] = k + pow2;
	a[1][2] = k;
	a[2][2] = k;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << 2 << " " << 3 << endl;
	ll ck = k;
	ll power = 0;
	while (ck != 1)
	{
		power++;
		ck /= 2;
	}
	power++;
	power = pow(2, power);
	cout << (power + k) << " " << k << " 0" << endl;
	cout << power << " " << (power + k) << " " << k << endl;
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << 2 << " " << 3 << endl;
	ll ck = k;
	ll power = log(k);
	power++;
	power = pow(2, power);
	cout << (power + k) << " " << k << " 0" << endl;
	cout << power << " " << (power + k) << " " << k << endl;
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << "2 3" << endl;
	ll a[2][2], num = k, pow2 = 1;
	mem(a, 0);
	while (num > 0)
	{
		pow2 *= 2;
		num /= 2;
	}
	a[0][0] = k + pow2;
	a[0][1] = k;
	a[1][0] = pow2;
	a[1][1] = k + pow2;
	a[1][2] = k;
	a[2][2] = k;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << "3 3" << endl;
	ll a[2][2], num = k, pow2 = 1;
	mem(a, 0);
	while (num > 0)
	{
		pow2 *= 2;
		num /= 2;
	}
	a[0][0] = k + pow2;
	a[0][1] = k;
	a[1][0] = pow2;
	a[1][1] = k + pow2;
	a[1][2] = k;
	a[2][2] = k;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


//@Shashank Keshav
//I want to listen to music lying on a riverbank and watch the auroras dance in the night sky

//<------------------------------------------Template------------------------------------------>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define acc accumulate
#define bin binary_search
#define vmin *min_element
#define vmax *max_element
#define max_pq priority_queue<ll, vll>
#define min_pq priority_queue<ll, vll, greater<ll>>
#define vstr vector<string>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define mll map<ll, ll>
#define umll unordered_map<ll, ll>
#define usll unordered_set<ll, ll>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(v) v.begin(), v.end()
#define mem(v, val) memset(v, val, sizeof(v))
#define rsort(v) sort(all(v), greater<ll>())
#define shflv(v) shuffle(all(v), rng)
#define shfla(a, n) shuffle(a, a + n, rng)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define preci(x, y) fixed << setprecision(y) << x
#define iter(it, a) for (auto &it : a)
#define fo(i, a, b) for (ll i = a; i < b; i++)
#define rfo(i, a, b) for (ll i = a; i >= b; i--)
#define arrin(arr, start, n) for (ll A = start; A < n; A++) cin >> arr[A];
#define ipmat(v,n,m) for (ll C = 0; C < n; C++) for (ll D = 0; D < m; D++) cin >> v[C][D];
#define print(arr, a, b) for (ll B = a; B < b; B++) cout << arr[B] << " "; cout << endl;
#define printmat(v, r, c) for (ll I = 0; I < r; I++) { for (ll J = 0; J < c; J++) cout << v[I][J] << " "; cout << endl; }
const ll mod = 1000000007;
const ll pmod = 998244353;
const ll maxN = 1000001;
#define PI 3.1415926535897932384626
#define inf LLONG_MAX
#define minf LLONG_MIN
#define FBO find_by_order
#define OOK order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define msg cout<<"Nikal laude pehli fursat mein nikal";

//<------------------------------------------Code------------------------------------------>

void cR()
{
	ll k;
	cin >> k;
	cout << "2 3" << endl;
	ll a[2][3], num = k, pow2 = 1;
	mem(a, 0);
	while (num > 0)
	{
		pow2 *= 2;
		num /= 2;
	}
	a[0][0] = k + pow2;
	a[0][1] = k;
	a[1][0] = pow2;
	a[1][1] = k + pow2;
	a[1][2] = k;
	a[2][2] = k;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input999.txt", "r", stdin);
	freopen("output999.txt", "w", stdout);
#endif
	ll T = 1;
	//cin>>T;
	while (T--)
	{
		cR();
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

	cin >> k;
	if(k == 0){
		cout << 1 << " " << 1 << '\n';
		cout << 300000 << '\n';
		return 0;
	}
	ll x = 1 << 17;
	cout << 2 << " " << 2 << '\n';
	cout << x + k  << " " << x << " " << 0 << '\n';
	cout << k << " " << x + k << " " << k << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

	cin >> k;
	if(k == 0){
		cout << 1 << " " << 1 << '\n';
		cout << 300000 << '\n';
	}
	ll x = 1 << 17;
	cout << 2 << " " << 2 << '\n';
	cout << x + k  << " " << x << " " << 0 << '\n';
	cout << k << " " << x + k << " " << k << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

	cin >> k;
	if(k == 0){
		cout << 1 << " " << 1 << '\n';
		cout << 300000 << '\n';
		return 0;
	}
	ll x = 1 << 17;
	cout << 2 << " " << 3 << '\n';
	cout << x + k  << " " << x << " " << 0 << '\n';
	cout << k << " " << x + k << " " << k << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

	cin >> k;
	ll x = 1 << 17;
	cout << 2 << " " << 2 << '\n';
	cout << x + k  << " " << x << " " << 0 << '\n';
	cout << k << " " << x + k << " " << k << '\n';
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    printf("%d\n",(int)pow(2,17));
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    printf("262143 131072 0\n");
    printf("%d 0 %d\n",k,k);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    printf("524287 262144 0\n");
    printf("%d 0 %d\n",k,k);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    printf("100005 0 0\n");
    printf("%d 0 %d\n",k,k);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int pow_(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans*=a;
        a*=a;
        b>>=1;
    }
    return ans;
}
int main()
{
    //printf("%d\n",pow_(2,18)-1);
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    printf("262143 131072 0\n");
    printf("%d 262143 %d\n",k,k);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    //printf("%d\n",(int)pow(2,17));
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    printf("262143 131072 0\n");
    printf("%d 0 %d\n",k,k);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inf=1<<17;
int main()
{
    ios::sync_with_stdio(false);
    int k;cin>>k;
    cout<<"2 2"<<endl;
    cout<<inf+k<<" "<<k<<endl;
    cout<<inf<<" "<<k;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1<<17;
int main()
{
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    cout<<"2 2"<<endl;
    cout<<inf+k<<" "<<k<<endl;
    cout<<inf<<" "<<k;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1<<20;
int main()
{
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    cout<<"2 2"<<endl;
    cout<<inf+k<<" "<<k<<;
    cout<<inf<<" "<<k;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inf=1<<17;
int dp[10][10];
int main()
{
    ios::sync_with_stdio(false);
    int k;cin>>k;
    cout<<"2 3"<<endl;
    cout<<inf+k<<" "<<k<<" 0"<<endl;
    cout<<inf<<" "<<inf+k<<" "<<k;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1<<20;
int main()
{
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    cout<<"2 2"<<endl;
    cout<<inf+k<<" "<<k<<endl;
    cout<<inf<<" "<<k;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k,n=2e17;
    cin>>k;
    cout<<2<<" "<<3<<endl;
    cout<<(n)+k<<" "<<n<<" "<<0<<endl;
    cout<<k<<" "<<(n)+k<<" "<<k<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>>k;
    cout<<2<<" "<<3<<endl;
    cout<<2e17+k<<" "<<2e17<<" "<<0<<endl;
    cout<<k<<" "<<2e17+k<<" "<<k<<endl;
}


#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll MAXN = 2e5 + 100;
const ll MAXM = 1e4 + 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void $main()
{
	ll k; cin >> k;

	ll x = 0, cur = 1;
	for (ll i = 0; i < 10; ++i)
		x += cur, cur <<= 1;

	cout << 3 << " " << 2 << '\n';
	cout << x << " " << (x ^ k) << '\n';
	cout << (x & k) << " " << x << '\n';
	cout << 0 << " " << k;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll MAXN = 2e5 + 100;
const ll MAXM = 1e4 + 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void $main()
{
	ll k; cin >> k;

	ll x = 0, cur = 1;
	for (ll i = 0; i < 13; ++i)
		x += cur, cur <<= 1;

	cout << 3 << " " << 2 << '\n';
	cout << x << " " << (x ^ k) << '\n';
	cout << (x & k) << " " << x << '\n';
	cout << 0 << " " << k;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll MAXN = 2e5 + 100;
const ll MAXM = 1e4 + 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void $main()
{
	ll k; cin >> k;

	ll x = 0, cur = 1;
	for (ll i = 0; i < 10; ++i)
		x += cur, cur <<= 1;

	cout << 2 << " " << 3 << '\n';
	cout << x << " " << (x ^ k) << '\n';
	cout << (x & k) << " " << x << '\n';
	cout << 0 << " " << k;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll MAXN = 2e5 + 100;
const ll MAXM = 1e4 + 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void $main()
{
	ll k; cin >> k;

	ll x = 0, cur = 1;
	for (ll i = 0; i < 16; ++i)
		x += cur, cur <<= 1;

	cout << 3 << " " << 2 << '\n';
	cout << x << " " << (x ^ k) << '\n';
	cout << (x & k) << " " << x << '\n';
	cout << 0 << " " << k;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll MAXN = 2e5 + 100;
const ll MAXM = 1e4 + 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void $main()
{
	ll k; cin >> k;

	ll x = 0, cur = 1;
	for (ll i = 0; i < 18; ++i)
		x += cur, cur <<= 1;

	cout << 3 << " " << 2 << '\n';
	cout << x << " " << (x ^ k) << '\n';
	cout << (x & k) << " " << x << '\n';
	cout << 0 << " " << k;

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int solve()
{
	ll k;cin>>k;
	ll b = (1<<17);

	cout<<3<<" "<<3<<"\n";
	cout<<b+k<<" "<<b<<" "<<0<<"\n";
	cout<<b+k<<" "<<b<<" "<<0<<"\n";
	cout<<k<<" "<<b+k<<" "<<k<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 500;
vvi mat(N,vi (N,0));

ll his_algo()
{
	ll n=5,m=5;
	vvi dp(N,vi (N,-1));
	dp[0][0]=mat[0][0];
	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if(dp[i][j]==-1) dp[i][j]=max((i-1>=0?dp[i-1][j]&mat[i][j]:0),(j-1>=0?dp[i][j-1]&mat[i][j]:0));
			// cout<<dp[i][j]<<" ";
		}
		// cout<<"\n";
	}

	return dp[n-1][m-1];
}

int solve()
{
	ll k;cin>>k;
	k*=2;
	ll n = 5,m = 5;
	ll dup = k;
	vi bit_rep;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	ll b = sz(bit_rep);

	b--;
	// whatis(b);

	rep(i,0,n) mat[i][0] = mat[i][0]|((ll)1<<b);
	rep(j,1,m) mat[n-1][j] = mat[n-1][j]|((ll)1<<b);
	rep(j,0,m-1) mat[0][j] = mat[0][j]|((ll)1<<(b+1));
	rep(i,1,n) mat[i][m-2] = mat[i][m-1]|((ll)1<<(b+1));

	rep(kk,1,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=((ll)1<<bit);
		rep(j,1,m) mat[n-1][j]|=((ll)1<<bit);
		mat[n-1][m-1]|=((ll)1<<bit);

	}

	bit_rep.clear();
	k = dup/2;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	rep(kk,0,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(j,0,m-1) mat[0][j] |=((ll)1<<bit);
		rep(i,1,n) mat[i][m-2] |=((ll)1<<bit);
		mat[n-1][m-1]|=((ll)1<<bit);
	}

	ll ans=mat[0][0];
	rep(i,0,n) ans&=mat[i][0];
	rep(j,0,m) ans&=mat[n-1][j];

	// his_algo();
	// whatis(ans);
	assert(ans-his_algo()==dup/2);

	cout<<n<<" "<<m<<"\n";
	rep(i,0,n) {rep(j,0,m) cout<<mat[i][j]<<" ";cout<<"\n";}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 500;
vvi mat(N,vi (N,0));

ll his_algo()
{
	ll n=5,m=5;
	vvi dp(N,vi (N,-1));
	dp[0][0]=mat[0][0];
	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if(dp[i][j]==-1) dp[i][j]=max((i-1>=0?dp[i-1][j]&mat[i][j]:0),(j-1>=0?dp[i][j-1]&mat[i][j]:0));
			// cout<<dp[i][j]<<" ";
		}
		// cout<<"\n";
	}

	return dp[n-1][m-1];
}

int solve()
{
	ll k;cin>>k;
	k*=2;
	ll n = 5,m = 5;
	ll dup = k;
	vi bit_rep;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	ll b = sz(bit_rep);

	b--;
	// whatis(b);

	rep(i,0,n) mat[i][0] = mat[i][0]|(1<<b);
	rep(j,1,m) mat[n-1][j] = mat[n-1][j]|(1<<b);
	rep(j,0,m-1) mat[0][j] = mat[0][j]|(1<<(b+1));
	rep(i,1,n) mat[i][m-2] = mat[i][m-1]|(1<<(b+1));

	rep(kk,1,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=(1<<bit);
		rep(j,1,m) mat[n-1][j]|=(1<<bit);
		mat[n-1][m-1]|=(1<<bit);

	}

	bit_rep.clear();
	k = dup/2;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	rep(kk,0,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(j,0,m-1) mat[0][j] |=(1<<bit);
		rep(i,1,n) mat[i][m-2] |=(1<<bit);
		mat[n-1][m-1]|=(1<<bit);
	}

	ll ans=mat[0][0];
	rep(i,0,n) ans&=mat[i][0];
	rep(j,0,m) ans&=mat[n-1][j];

	// his_algo();
	// whatis(ans);
	assert(ans-his_algo()==dup/2);

	cout<<n<<" "<<m<<"\n";
	rep(i,0,n) {rep(j,0,m) cout<<mat[i][j]<<" ";cout<<"\n";}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 500;
vvi mat(N,vi (N,0));

// ll his_algo()
// {
// 	vvi dp(N,vi (N,-1));
// 	dp[0][0]=mat[0][0];
// 	rep(i,0,n)
// 	{
// 		rep(j,0,m)
// 		{
// 			if(dp[i][j]==-1) dp[i][j]=max((i-1>=0?dp[i-1][j]&mat[i][j]:0),(j-1>=0?dp[i][j-1]&mat[i][j]:0));
// 			cout<<dp[i][j]<<" ";
// 		}
// 		cout<<"\n";
// 	}

// 	return dp[n-1][m-1];
// }

int solve()
{
	ll k;cin>>k;
	k*=2;
	ll n = 5,m = 5;
	ll dup = k;
	vi bit_rep;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	ll b = sz(bit_rep);

	b--;
	// whatis(b);

	rep(i,0,n) mat[i][0] = mat[i][0]|(1<<b);
	rep(j,1,m) mat[n-1][j] = mat[n-1][j]|(1<<b);
	rep(j,0,m-1) mat[0][j] = mat[0][j]|(1<<(b+1));
	rep(i,1,n) mat[i][m-2] = mat[i][m-1]|(1<<(b+1));

	rep(kk,0,sz(bit_rep)-1)
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=(1<<bit);
		rep(j,1,m) mat[n-1][j]|=(1<<bit);
	}

	bit_rep.clear();
	k = dup/2;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	rep(kk,0,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=(1<<bit);
		rep(j,1,m) mat[n-1][j]|=(1<<bit);
	}

	mat[n-1][m-1] = dup;

	cout<<n<<" "<<m<<"\n";
	rep(i,0,n) {rep(j,0,m) cout<<mat[i][j]<<" ";cout<<"\n";}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int solve()
{
	ll k;cin>>k;
	ll b = (1<<17);

	cout<<3<<" "<<3<<"\n";
	cout<<b+k<<" "<<b<<" "<<0<<"\n";
	cout<<b+k<<" "<<b<<" "<<0<<"\n";
	cout<<b+k<<" "<<b+k<<" "<<k<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 500;
vvi mat(N,vi (N,0));

// ll his_algo()
// {
// 	vvi dp(N,vi (N,-1));
// 	dp[0][0]=mat[0][0];
// 	rep(i,0,n)
// 	{
// 		rep(j,0,m)
// 		{
// 			if(dp[i][j]==-1) dp[i][j]=max((i-1>=0?dp[i-1][j]&mat[i][j]:0),(j-1>=0?dp[i][j-1]&mat[i][j]:0));
// 			cout<<dp[i][j]<<" ";
// 		}
// 		cout<<"\n";
// 	}

// 	return dp[n-1][m-1];
// }

int solve()
{
	ll k;cin>>k;
	ll n = N,m = N;
	vi bit_rep;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	ll b = sz(bit_rep);

	// whatis((0|(1<<0)));

	rep(i,0,n) mat[i][0] = mat[i][0]|(1<<b);
	rep(j,1,m) mat[n-1][j] = mat[n-1][j]|(1<<b);
	rep(j,0,m-1) mat[0][j] = mat[0][j]|(1<<(b+1));
	rep(i,1,n) mat[i][m-1] = mat[i][m-1]|(1<<(b+1));

	for(ll bit = b-1;bit>=0;bit--) rep(i,0,n) rep(j,0,m) mat[i][j]|=(1<<bit);

	cout<<n<<" "<<m<<"\n";
	rep(i,0,n) {rep(j,0,m) cout<<mat[i][j]<<" ";cout<<"\n";}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 500;
vvi mat(N,vi (N,0));

// ll his_algo()
// {
// 	vvi dp(N,vi (N,-1));
// 	dp[0][0]=mat[0][0];
// 	rep(i,0,n)
// 	{
// 		rep(j,0,m)
// 		{
// 			if(dp[i][j]==-1) dp[i][j]=max((i-1>=0?dp[i-1][j]&mat[i][j]:0),(j-1>=0?dp[i][j-1]&mat[i][j]:0));
// 			cout<<dp[i][j]<<" ";
// 		}
// 		cout<<"\n";
// 	}

// 	return dp[n-1][m-1];
// }

int solve()
{
	ll k;cin>>k;
	k*=2;
	ll n = 5,m = 5;
	ll dup = k;
	vi bit_rep;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	ll b = sz(bit_rep);

	b--;
	// whatis(b);

	rep(i,0,n) mat[i][0] = mat[i][0]|(1<<b);
	rep(j,1,m) mat[n-1][j] = mat[n-1][j]|(1<<b);
	rep(j,0,m-1) mat[0][j] = mat[0][j]|(1<<(b+1));
	rep(i,1,n) mat[i][m-2] = mat[i][m-1]|(1<<(b+1));

	rep(kk,1,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=(1<<bit);
		rep(j,1,m) mat[n-1][j]|=(1<<bit);
	}

	bit_rep.clear();
	k = dup/2;
	while(k) bit_rep.pb(k%2),k/=2;
	reverse(bit_rep.begin(), bit_rep.end());

	rep(kk,0,sz(bit_rep))
	{
		if(bit_rep[kk]==0) continue;
		ll bit = sz(bit_rep)-1-kk;
		rep(i,0,n) mat[i][0]|=(1<<bit);
		rep(j,1,m) mat[n-1][j]|=(1<<bit);
	}

	mat[n-1][m-1] = dup;

	cout<<n<<" "<<m<<"\n";
	rep(i,0,n) {rep(j,0,m) cout<<mat[i][j]<<" ";cout<<"\n";}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t=1;
 while(t--){
    int n;
    cin>>n;
    int x=n;
    int pow=0;
    int ok=1<<posbit(n);
    int sec=ok|n;
    cout<<2<<" "<<3<<endl;
    cout<<sec<<" "<<n<<" "<<n<<endl;
    cout<<sec<<" "<<sec<<" "<<n<<endl;

 }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t;
 cin>>t;
 while(t--){
    int n;
    cin>>n;
    int x=n;
    int pow=0;
    int ok=1<<posbit(n);
    int sec=ok|n;
    cout<<2<<" "<<3<<endl;
    cout<<sec<<" "<<n<<" "<<n<<endl;
    cout<<ok<<" "<<ok<<" "<<n<<endl;

 }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t=1;
 while(t--){
    int n;
    cin>>n;
    int x=n;
    int pow=0;
    int ok=1<<posbit(n);
    int sec=ok|n;
    cout<<2<<" "<<3<<endl;
    cout<<sec<<" "<<n<<" "<<n<<endl;
    cout<<sec<<" "<<ok<<" "<<n<<endl;

 }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t=1;
 while(t--){
    int k;
    cin>>k;

    cout<<2<<" "<<3<<endl;
    cout<<(1<<17)+k<<" "<<(1<<17)<<" "<<0<<endl;
    cout<<k<<" "<<(1<<17)+k<<" "<<k<<endl;

 }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t=1;
 while(t--){
    int n;
    cin>>n;
    int x=n;
    int pow=0;

    int ok=1<<posbit(n);

    int sec=ok|n;
    cout<<2<<" "<<3<<endl;
    cout<<sec<<" "<<n<<" "<<n<<endl;
    cout<<sec<<" "<<ok<<" "<<sec<<endl;

 }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int posbit(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb;
}
int main()
{
 int t=1;
 while(t--){
    int n;
    cin>>n;
    int x=n;
    int pow=0;
    int ok=1<<posbit(n);
    int sec=ok|n;
    cout<<2<<" "<<3<<endl;
    cout<<sec<<" "<<n<<" "<<n<<endl;
    cout<<ok<<" "<<ok<<" "<<n<<endl;

 }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
			fast
			#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
			#endif

	     	ll k;
			 cin>>k;
			 cout<<3<<" "<<2<<endl;
			 ll x=pow(2,17);

			 cout<<x+k<<" "<<x<<" "<<0<<endl;
			 cout<<x<<" "<<x+k<<" "<<k<<endl;

			return 0;
		 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
			fast
			#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
			#endif

	     	ll x;
			 cin>>x;
			 cout<<2<<" "<<2<<endl;
			 cout<<x<<" "<<x<<endl;
			 cout<<x<<" "<<x<<endl;

			return 0;
		 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
			fast
			#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
			#endif

	     	ll x;
			 cin>>x;
			 cout<<2<<" "<<2<<endl;
			 cout<<x<<" "<<0<<endl;
			 cout<<0<<" "<<0<<endl;

			return 0;
		 }


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
			fast
			#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
			#endif

	     	ll k;
			 cin>>k;
			 cout<<2<<" "<<3<<endl;
			 ll x=pow(2,17);

			 cout<<x+k<<" "<<x<<" "<<0<<endl;
			 cout<<k<<" "<<x+k<<" "<<k<<endl;

			return 0;
		 }


#include<bits/stdc++.h>
using namespace std;

int main() {
    int k;
    cin>>k;
    cout<<2<<" "<<2<<endl;
    cout<<k<<" "<<k<<endl;
    cout<<(1<<k)<<" "<<k<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int k;
    cin>>k;
    cout<<k<<" "<<k<<endl;
    cout<<(1<<k)<<" "<<k<<endl;
}


#include<bits/stdc++.h>
using namespace std;

int main() {
    int k;
    cin>>k;
    cout<<2<<" "<<2<<endl;
    cout<<(k|(1<<k))<<" "<<k<<endl;
    cout<<(1<<k)<<" "<<k<<endl;
}


import java.io.*
import java.util.*

private fun solve() {

    val n = nextInt()

    repeat(n) {
        val L = nextInt()
        val v = nextInt()
        val l = nextInt()
        val r = nextInt()

        println(L / v - r / v + (l - 1) / v)
    }
}

private fun hasNext(): Boolean {
    while (!st.hasMoreTokens()) {
        st = StringTokenizer(input.readLine() ?: return false)
    }
    return true
}

private fun next() = if (hasNext()) st.nextToken()!! else throw RuntimeException("No tokens")

private fun nextInt() = next().toInt()

private fun nextLong() = next().toLong()

private fun nextDouble() = next().toDouble()

private fun nextLine() = if (hasNext()) st.nextToken("\n")!! else throw RuntimeException("No tokens")

private fun nextArray(n: Int) = IntArray(n) { nextInt() }

private val ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null

private var input = when (ONLINE_JUDGE) {
    true -> BufferedReader(InputStreamReader(System.`in`), 32768)
    else -> BufferedReader(FileReader("in.txt"))
}

private var output = when (ONLINE_JUDGE) {
    true -> PrintWriter(BufferedWriter(OutputStreamWriter(System.out)))
    else -> PrintWriter(BufferedWriter(FileWriter("out.txt")))
}

private var st = StringTokenizer("")

fun main() {
    val start = System.currentTimeMillis()
    solve()

    output.close()
    input.close()

    if (!ONLINE_JUDGE) {
        System.err.println("\n${System.currentTimeMillis() - start} ms")
    }
}