#include <bits/stdc++.h>
using namespace std;
#define LL             long long int
#define ulli           unsigned long long int
#define li             long int
#define ff(i,a,b)      for(int i=a;i<b;i++)
#define fb(i,b,a)      for(int i=b;i>=a;i--)
#define w(t)           while(--t >= 0)
#define l(s)           s.length()
#define ci(n)          cin>>n;
#define fast           ios_base::sync_with_stdio(false);
#define sa(a,n)        sort(a,a+n)
#define sv(v)          sort(v.begin(),v.end())
#define cy             cout<<"YES\n"
#define cn             cout<<"NO\n"
#define nl             cout<<"\n"
#define minus          cout<<"-1\n";
#define vi             vector<int>
#define pb             push_back
#define tc             int t; cin>>t;
#define pp             pair<int,int>
#define input(a,n)     for(int i=0;i<n;i++) cin>>a[i];
#define co(n)          cout<<n;
#define ret            return 0
#define mi             map<int,int>
#define output(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define forn(i, n)     ff(i, 0, n)
#define sz(v)          int((v).size())
#define N 111

int n, cnt = 1, a[110][110];
int main()
{
	cin >> n;
	while (n > 0)
	{
		for (int i = 0; i <= n; i++)
		{
			if (i >= cnt)
			{
				break;
			}
			a[i][cnt] = 1;
			a[cnt][i] = 1;
			n -= i;
		}
		cnt++;
	}
	cout<<cnt;
	nl;
	for (int i = 0; i < cnt; i++)
	{
		for (int j = 0; j < cnt; j++)
		{
			cout << a[i][j];
		}
		nl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LL             long long int
#define ulli           unsigned long long int
#define li             long int
#define ff(i,a,b)      for(int i=a;i<b;i++)
#define fb(i,b,a)      for(int i=b;i>=a;i--)
#define w(t)           while(--t >= 0)
#define l(s)           s.length()
#define ci(n)          cin>>n;
#define fast           ios_base::sync_with_stdio(false);
#define sa(a,n)        sort(a,a+n)
#define sv(v)          sort(v.begin(),v.end())
#define cy             cout<<"YES\n"
#define cn             cout<<"NO\n"
#define nl             cout<<"\n"
#define minus          cout<<"-1\n";
#define vi             vector<int>
#define pb             push_back
#define tc             int t; cin>>t;
#define pp             pair<int,int>
#define input(a,n)     for(int i=0;i<n;i++) cin>>a[i];
#define co(n)          cout<<n;
#define ret            return 0
#define mi             map<int,int>
#define output(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define forn(i, n)     ff(i, 0, n)
#define sz(v)          int((v).size())
#define N 111

int n, cnt = 1, a[110][110];
int main()
{
	cin >> n;
	while (n > 0)
	{
		for (int i = 0; i <= n; i++)
		{
			if (i == cnt)
			{
				break;
			}
			a[i][cnt] = 1;
			a[cnt][i] = 1;
			n -= i;
		}
		cnt++;
	}
	cout<<cnt;
	nl;
	for (int i = 0; i < cnt; i++)
	{
		for (int j = 0; j < cnt; j++)
		{
			cout << a[i][j];
		}
		nl;
	}
	return 0;
}


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

int nad3(int n) {
    return n * (n-1) * (n-2) / 6;
}

int nad2(int n) {
    return n * (n-1) / 2;
}

int ans[102][102];

int main()
{
    int k; cin >> k;

    int n;

    for (n = 3; n <= 100; n++) {
        if (nad3(n) > k) break;
    }

    n = n - 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
                ans[i][j] = i != j;

    k -= nad3(n);

    while (k != 0) {
        int x;
        for (x = 2; x <= n; x++) {
            if (nad2(x) > k) break;
        }
        x = x - 1;
        n++;
        for (int i = 1; i <= x; i++)
            ans[n][1] = ans[1][n] = 1;
        k -= nad2(x);
    }

    cout << n << '\n';
    for (int i = 1; i <= n; i++)        {
        for (int j = 1; j <= n; j++)
            cout << ans[i][j];
        cout << '\n';                   }
}


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

int nad3(int n) {
    return n * (n-1) * (n-2) / 6;
}

int nad2(int n) {
    return n * (n-1) / 2;
}

int ans[102][102];

int main()
{
    int k; cin >> k;

    int n;

    for (n = 3; n <= 100; n++) {
        if (nad3(n) > k) break;
    }

    n = n - 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
                ans[i][j] = i != j;

    k -= nad3(n);

    while (k != 0) {
        int x;
        for (x = 1; x <= k; x++) {
            if (nad2(x) > k) break;
        }
        x = x - 1;
        n++;
        for (int i = 1; i <= x; i++)
            ans[n][1] = ans[1][n] = 1;
        k -= nad2(x);
    }

    cout << n << '\n';
    for (int i = 1; i <= n; i++)        {
        for (int j = 1; j <= n; j++)
            cout << ans[i][j];
        cout << '\n';                   }
}


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

int nad3(int n) {
    return n * (n-1) * (n-2) / 6;
}

int nad2(int n) {
    return n * (n-1) / 2;
}

int ans[102][102];

int main()
{
    int k; cin >> k;

    int n;

    for (n = 3; n <= 100; n++) {
        if (nad3(n) > k) break;
    }

    n = n - 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
                ans[i][j] = i != j;

    k -= nad3(n);

    while (k != 0) {
        int x;
        for (x = 2; x <= n; x++) {
            if (nad2(x) > k) break;
        }
        x = x - 1;
        n++;
        for (int i = 1; i <= x; i++)
            ans[n][i] = ans[i][n] = 1;
        k -= nad2(x);
    }

    cout << n << '\n';
    for (int i = 1; i <= n; i++)        {
        for (int j = 1; j <= n; j++)
            cout << ans[i][j];
        cout << '\n';                   }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 100 + 5;

int t, n = 100;
bool adj[N][N];

int cycles(int u, int v) {
    int c = 0;
    for (int i = 1; i <= n; i++) {
        c += adj[u][i] and adj[v][i];
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> t;

    for (int i = 1; i <= n && t; i++) {
        for (int j = i + 1; j <= n && t; j++) {
            int ans = cycles(i, j);
            if (ans > t)
                continue;
            t -= ans;
            adj[i][j] = adj[j][i] = true;
        }
    }

    cout << n << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << adj[i][j];
        }
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 100 + 5;

int target;
bool adj[N][N];

int f(int x) {
    return (x * (x - 1) * (x - 2)) / 6;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> target;

    int n = 1;

    for (int i = 1; i <= 100 && target; i++) {
        for (int j = i + 1; j <= 100 && target; j++) {
            for (int k = j + 1; k <= 100 && target; k++) {
                adj[i][j] = adj[j][i] = true;
                adj[j][k] = adj[k][j] = true;
                adj[i][k] = adj[k][i] = true;
                target--;
                n = max(n, k);
            }
        }
    }

    cout << n << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << adj[i][j];
        }
        cout << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 100 + 5;

int k, n = 2, i = 0;
bool adj[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> k;

    while (k > 0) {
        if (k < i) i = 0, n++;
        adj[n - 1][i] = adj[i][n - 1] = true;
        k -= i;
        i++;
        if (i >= n - 1 && k) i = 0, n++;
    }

    cout << n << "\n";
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << adj[i][j];
        }
        cout << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=107;
int n,c3[N],c2[N],a[N][N];
int main(){
	for(int i=3;i<=100;i++)c3[i]=i*(i-1)*(i-2)/6;
	for(int i=2;i<=100;i++)c2[i]=i*(i-1)/2;
	cin>>n;
	int pre;
	for(int i=3;i<=100;i++)if(c3[i]<=n)pre=i;
	for(int i=1;i<=pre;i++)
	for(int j=1;j<=pre;j++)if(i!=j)a[i][j]=1;
	n-=c3[pre];
	int extend=pre;
	while(n){
		extend++;
		int k=0;
		for(int i=2;i<=pre;i++)if(c2[i]<=n)k=i;
		for(int i=1;i<=k;i++)a[i][extend]=a[extend][i]=1;
		n-=c2[k];
	}
	cout<<extend<<endl;
	for(int i=1;i<=extend;i++){
		for(int j=1;j<=extend;j++)printf("%d ",a[i][j]);
		puts("");
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=107;
int n,c3[N],c2[N],a[N][N];
int main(){
	for(int i=3;i<=100;i++)c3[i]=i*(i-1)*(i-2)/6;
	for(int i=2;i<=100;i++)c2[i]=i*(i-1)/2;
	cin>>n;
	int pre;
	for(int i=3;i<=100;i++)if(c3[i]<=n)pre=i;
	for(int i=1;i<=pre;i++)
	for(int j=1;j<=pre;j++)if(i!=j)a[i][j]=1;
	n-=c3[pre];
	int extend=pre;
	while(n){
		extend++;
		int k=0;
		for(int i=2;i<=pre;i++)if(c2[i]<=n)k=i;
		for(int i=1;i<=k;i++)a[i][extend]=a[extend][i]=1;
		n-=c2[k];
	}
	cout<<extend<<endl;
	for(int i=1;i<=extend;i++){
		for(int j=1;j<=extend;j++)printf("%d",a[i][j]);
		puts("");
	}
}


/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;

#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<"\n";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds

void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}

int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851

vvi ncr(1001,vi(1001));
void ncrBuild(){
    ncr[0][0]=1;
    for(int i=1;i<1001;i++)ncr[i][0]=1;
    for(int i=1;i<1001;i++){
        for(int j=1;j<1001;j++){
            ncr[i][j]=ncr[i-1][j]+ncr[i-1][j-1];
        }
    }
}

int32_t main(){
    read();
    ncrBuild();
    vi arr;
    for(int i=1;i<=100;i++)
        arr.pb(ncr[i][3]);
    int n; cin>>n;
    int co = upper_bound(all(arr),n)-arr.begin();
    int m=n-arr[co-1];
    vi rest;
    while(m){
        int coount = 1;
        int curr = 0;
        while(curr+coount<=m){
            curr+=coount;
            coount++;
        }
        m-=curr;
        rest.pb(coount);
    }
    cout<<co+rest.size()<<endl;
    vs edges(co+rest.size(),string(co+rest.size(),'0'));
    for(int i=1;i<=co;i++)
        for(int j=i+1;j<=co;j++)
            edges[i-1][j-1] = '1',edges[j-1][i-1] = '1';
    for(int i=0;i<rest.size();i++){
        co++;
        for(int j=1;j<=rest[i];j++)
            edges[co-1][j-1] = '1',edges[j-1][co-1] = '1';
    }
    p1d(edges);
}


#include<bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i < (b); i++)
#define _count(i, a, b) for (int i = (a); i <= b; i++)
#define PB emplace_back
#define MINI -2147483648
#define MAXI 2147483647
#define MAXLL 9223372036854775807
#define MINLL -9223372036854775808
#define VI vector<int>
#define VB vector<bool>
#define VLL vector<long long>
#define LL long long
#define ULL unsigned long long
#define ALL(X) X.begin(), X.end()
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
//#define Remilia_is_so_cute
#define StarBurst std::ios::sync_with_stdio(false),cin.tie(NULL);
#define lowerBit(x) x&-x
using namespace std;

inline void R_P(vector<int> &vec) {
  int temp;
  cin>>temp;
  vec.push_back(temp);
}
inline bool checkMax(int &base, int test) {
  return (test > base) ? base = test, true : false;
}

inline bool checkMin(int &base, int test){
  return (test < base)? base = test, true : false;
}
template <class T>
void test(vector<T> &vec, const string &warn) {
  cout<<warn<<'\n';
  _for(i, 0, vec.size())
    cout<<vec[i]<<' ';
  cout<<"\nTest end..............\n";
}

VI Clist(85, 0);
VI sum(83, 0);
void build() {
  Clist[3] = 1;
  _for(i, 4, 85)
    Clist[i] = Clist[i - 1] * i / (i - 3);
  _for(i, 1, 83)
    sum[i] = sum[i - 1] + i;
}

int main () {
  StarBurst
  #ifdef Remilia_is_so_cute
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  build();
  int k; cin >> k;

  int tmp;
  vector<int> ans;

  tmp = upper_bound(ALL(Clist), k) - Clist.begin() - 1;
  k -= Clist[tmp];

  while(k > 0) {
    int b = upper_bound(ALL(sum), k) - sum.begin() - 1;
    b = min(b, tmp - 1);
    k -= sum[b];
    ans.PB(b + 1);
  }

  vector<VB> graph(tmp + ans.size(), VB(tmp + ans.size(), false));
  _for(i, 0, tmp)
    _for(j, 0, tmp)
      if (i != j)
        graph[i][j] = true;

  _for(i, 0, ans.size()) {
    int pos = i + tmp;
    int cur = 0;
    _for(j, 0, tmp) {
      if (pos == j)
        continue;
      graph[pos][j] = true;
      graph[j][pos] = true;
      cur++;
      if (cur >= ans[i])
        break;
    }
  }

  cout << graph.size() << '\n';
  for(VB VEC : graph) {
    for(bool X : VEC)
      cout << ((X) ? '1' : '0');
    cout << '\n';
  }

  return 0;
}


#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <iterator>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define in insert
#define er erase

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define P acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

char c[181][181];

int n, i, j, k, sum;

bool x;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> k;

    for (i = 1; i <= 100; i++)
        for (j = 1; j <= 100; j++) c[i][j] = '0';

    n = 1;

    while (k > 0) {
        n++;

        for (i = 1; i <= n - 1; i++) {
            if (k - (i - 1) >= 0) {
                k -= i - 1;

                c[n][i] = c[i][n] = '1';

                cont;
            }

            break;
        }
    }

    cout << n << endl;

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) cout << c[i][j];

        cout << endl;
    }

    re 0;
}


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

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

void func()
{
  ll k;
  cin>>k;
  ll n=3,x=1;
  f(i,4,101)
  {
    ll temp=(i*(i-1)*(i-2))/6;
    if(temp<=k)
    {
      //cout<<"taa taa\n";
      n=i;
      x=temp;
    }
    else break;
  }
  list<ll>adj[101];

  f(i,1,n+1)
  {
    f(j,1,n+1)
    {
      if(i==j) continue;
      else adj[i].pb(j);
    }
  }

  ll cnt=k-x,nm=0;
  //cout<<"bye bye\n";
  //cout<<cnt<<endl;
  f(i,1,n+1)
  {
    if(i*(i-1)/2<=cnt)
    {
      nm=i;
    }
    else break;
  }
  //cout<<n<<endl;
  cnt-=((nm*(nm-1))/2);
  //cout<<nm<<endl;
  f(i,1,nm+1)
  {
    //cout<<"moshi moshi\n";
    adj[n+1].pb(i);
    //cout<<n+1<<"  "<<i<<endl;
    adj[i].pb(n+1);
    //pr2(i,n+1) nl
  }

  adj[n+1].pb(n+2);
  adj[n+2].pb(n+1);

  f(i,1,cnt+1)
  {
    adj[n+2].pb(i);
    adj[i].pb(n+2);
  }

  ll ans[101][101];
  f(i,1,101) f(j,1,101) ans[i][j]=0;

  f(i,1,101)
  {
    for(auto j:adj[i]) ans[i][j]=1;
  }
  cout<<"100\n";
  f(i,1,101)
  {
    f(j,1,101) cout<<ans[i][j];
    nl
  }
}

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

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}


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

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

void func()
{
  ll k;
  cin>>k;
  ll n=3,x=1;
  f(i,4,101)
  {
    ll temp=(i*(i-1)*(i-2))/6;
    if(temp<=k)
    {
      //cout<<"taa taa\n";
      n=i;
      x=temp;
    }
    else break;
  }
  list<ll>adj[101];

  f(i,1,n+1)
  {
    f(j,1,n+1)
    {
      if(i==j) continue;
      else adj[i].pb(j);
    }
  }

  ll cnt=k-x,curr=n+1;
  while(cnt)
  {
    ll x=1;
    f(i,2,n+1)
    {
      if(i*(i-1)/2<=cnt)
      {
        x=i;
      }
      else break;
    }
    f(i,1,x+1)
    {
      adj[curr].pb(i);
      adj[i].pb(curr);
    }
    cnt-=(x*(x-1))/2;
    curr++;
  }
  //cout<<"bye bye\n";
  /*cout<<cnt<<endl;
  f(i,1,n+1)
  {
    if(i*(i-1)/2<=cnt)
    {
      nm=i;
    }
    else break;
  }
  //cout<<n<<endl;
  cnt-=((nm*(nm-1))/2);
  //cout<<nm<<endl;
  pr(cnt) nl
  f(i,1,nm+1)
  {
    //cout<<"moshi moshi\n";
    adj[n+1].pb(i);
    //cout<<n+1<<"  "<<i<<endl;
    adj[i].pb(n+1);
    //pr2(i,n+1) nl
  }

  adj[n+1].pb(n+2);
  adj[n+2].pb(n+1);

  f(i,1,cnt+1)
  {
    adj[n+2].pb(i);
    adj[i].pb(n+2);
  }*/

  ll ans[101][101];
  f(i,1,101) f(j,1,101) ans[i][j]=0;

  f(i,1,101)
  {
    for(auto j:adj[i]) ans[i][j]=1;
  }
  cout<<"100\n";
  f(i,1,101)
  {
    f(j,1,101) cout<<ans[i][j];
    nl
  }
}

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

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 105;

int a[N][N];

int nC2(int n) {
	return n * (n - 1) / 2;
}

int nC3(int n) {
	return n * (n - 1) * (n - 2) / 6;
}

int32_t main() {
	IOS;
	int n;
	cin >> n;
	int reqd = 0, three = 0;
	for (int i = 3; i <= 100; i++) {
		if (nC3(i) <= n) {
			three = i;
		}
	}
	reqd = three;
	n -= nC3(three);
	for (int i = 1; i <= three; i++) {
		for (int j = 1; j <= three; j++) {
			if (i != j)
				a[i][j] = 1;
		}
	}

	while (n) {
		int two = 0;
		for (int i = 2; i <= 100; i++) {
			if (nC2(i) <= n) {
				two = i;
			}
		}
		n -= nC2(two);
		reqd++;
		for (int i = 1; i <= two; i++) {
			a[i][reqd] = a[reqd][i] = 1;
		}
	}

	cout << reqd << endl;
	for (int i = 1; i <= reqd; i++) {
		for (int j = 1; j <= reqd; j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

bool adj[200][200];

void add(int a, int b)
{
    adj[a][b] = true;
    adj[b][a] = true;
}

void remove(int a, int b)
{
    adj[a][b] = false;
    adj[b][a] = false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;

    long long sz = 3;
    while (sz * (sz - 1) * (sz - 2) / 6 <= n)
        sz ++;
    // make a complete graph of size sz
    sz --;
    for (int i = 0; i < sz; i++)
        for (int j = 0; j < sz; j++)
            if (i != j)
                adj[i][j] = true;
    n -= sz * (sz - 1) * (sz - 2) / 6;
    while (n > 0)
    {
        sz ++;
        // number of vertices to add;
        int d;
        for (d = 2; d * (d -1) / 2 <= n; d++);
        d--;
        // now we have to add edges to 0..d
        for (int i = 0; i < d; i ++)
        {
            adj[i][d] = true;
            adj[d][i] = true;
        }
        n -= d * (d-1) / 2;
    }
    cout << sz << "\n";
    for (int i = 0; i < sz; i++)
    {
        for (int j = 0; j < sz; j++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;
    vector<vector<bool>> adj(200, vector<bool> (200, false));

    int st = 0;
    while (n > 0)
    {
        int val = 1;
        int a, b;
        a = st;
        b = st + 1;
        adj[a][b] = true;
        adj[b][a] = true;
        st += 2;
        while(n >= val)
        {
            adj[a][st] = adj[b][st] = true;
            adj[st][a] = adj[st][b] = true;
            st += 1;
            val += val;
        }
        n -= val / 2;
    }
    cout << st << "\n";
    for (int i = 0; i < st; i++)
    {
        for (int j = 0; j < st; j ++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

bool adj[200][200];

void add(int a, int b)
{
    adj[a][b] = true;
    adj[b][a] = true;
}

void remove(int a, int b)
{
    adj[a][b] = false;
    adj[b][a] = false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;
    memset(adj, 0, sizeof(adj));
    long long added = 0;
    for (int i = 0; i < 100; i ++)
    {
        for (int j = i + 1; j < 100; j ++)
        {
            if (adj[i][j])
                continue;
            // add edge i, j
            add(i, j);
            // now we count new edges added;
            int new_cc = 0;
            for (int x = 0; x < 100; x++)
            {
                if (x == i or x == j)
                    continue;
                if (adj[x][i] and adj[i][j] and adj[x][j])
                {
                    new_cc ++;
                }
            }
            if (new_cc + added <= n)
            {
                added += new_cc;
            } else
            {
                remove(i, j);
            }
        }
    }

    if (added != n)
        cout << "-1";
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;
    vector<vector<bool>> adj(200, vector<bool> (200, false));

    int st = 0;
    while (n > 0)
    {
        if (n == 1)
        {
            adj[st][st + 1] = adj[st + 1][st + 2] = adj[st + 2][st] = true;
            adj[st + 1][st] = adj[st + 2][st + 1] = adj[st][st + 2] = true;

            st += 3;
            n -= 1;
        }
        else {
            int val = 1;

            int a, b, c;
            a = st;
            c = st + 1;
            b = st + 2;
            adj[a][c] = true;
            adj[b][c] = true;

            adj[c][a] = true;
            adj[c][b] = true;

            // cout << a << " " << b << endl;
            st += 3;
            while (n >= val) {
                adj[a][st] = adj[b][st] = true;
                adj[st][a] = adj[st][b] = true;
                // cout << st << " " << a << " " << b << endl;
                st += 1;
                val += val;
            }
            cout << endl;
            n -= val / 2;
        }
    }
    cout << st << "\n";
    for (int i = 0; i < st; i++)
    {
        for (int j = 0; j < st; j ++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;
    vector<vector<bool>> adj(200, vector<bool> (200, false));

    int st = 0;

    vector<int> vs;
    vs.push_back(st);
    vs.push_back(st + 1);
    vs.push_back(st + 2);
    adj[st + 0][st + 1] = adj[st + 1][st + 2] = adj[st + 2][st + 0] = true;
    adj[st + 1][st + 0] = adj[st + 2][st + 1] = adj[st + 0][st + 2] = true;
    n -= 1;
    st = 3;
    while (n > 0) {
        int nv = st;
        st ++;
        adj[vs[0]][nv] = true;
        adj[nv][vs[0]] = true;
        for (int i = 1; i < vs.size(); i++) {
            int x = vs[i];
            adj[x][nv] = true;
            adj[nv][x] = true;
            n --;
            if (n == 0)
                break;
        }
        vs.push_back(nv);
    }
    cout << st << "\n";
    for (int i = 0; i < st; i++)
    {
        for (int j = 0; j < st; j ++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

bool adj[200][200];

void add(int a, int b)
{
    adj[a][b] = true;
    adj[b][a] = true;
}

void remove(int a, int b)
{
    adj[a][b] = false;
    adj[b][a] = false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;

    long long sz = 3;
    while (sz * (sz - 1) * (sz - 2) / 6 <= n)
        sz ++;
    // make a complete graph of size sz
    sz --;
    for (int i = 0; i < sz; i++)
        for (int j = 0; j < sz; j++)
            if (i != j)
                adj[i][j] = true;
    n -= sz * (sz - 1) * (sz - 2) / 6;
    while (n > 0)
    {
        sz ++;
        // number of vertices to add;
        int d;
        for (d = 2; d * (d -1) / 2 <= n; d++);
        d--;
        // now we have to add edges to 0..d
        for (int i = 0; i < d; i ++)
        {
            adj[i][sz-1] = true;
            adj[sz-1][i] = true;
        }
        n -= d * (d-1) / 2;
    }
    cout << sz << "\n";
    for (int i = 0; i < sz; i++)
    {
        for (int j = 0; j < sz; j++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

bool adj[200][200];

void add(int a, int b)
{
    adj[a][b] = true;
    adj[b][a] = true;
}

void remove(int a, int b)
{
    adj[a][b] = false;
    adj[b][a] = false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n;
    cin >> n;

    long long sz = 3;
    while (sz * (sz - 1) * (sz - 2) / 6 <= n)
        sz ++;
    // make a complete graph of size sz
    sz --;
    for (int i = 0; i < sz; i++)
        for (int j = 0; j < sz; j++)
            if (i != j)
                adj[i][j] = true;
    n -= sz * (sz - 1) * (sz - 2);
    while (n > 0)
    {
        sz ++;
        // number of vertices to add;
        int d;
        for (d = 2; d * (d -1) / 2 <= n; d++);
        d--;
        // now we have to add edges to 0..d
        for (int i = 0; i < d; i ++)
        {
            adj[i][d] = true;
            adj[d][i] = true;
        }
        n -= d * (d-1) / 2;
    }
    cout << sz << "\n";
    for (int i = 0; i < sz; i++)
    {
        for (int j = 0; j < sz; j++)
            cout << adj[i][j];
        cout << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=2;
        while(e*(e-1)/2<=k and e<q)e++;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=0;
        while(e*(e+1)/2<=k and e<q)e++;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    cout<<100<<endl;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=2;
        while(e*(e-1)/2<=k and e<q)e++;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    cout<<100<<endl;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=2;
        while(e*(e-1)/2<=k and e<q)e++;
        if(e<q)
            e--;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    cout<<100<<endl;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=0;
        while(e*(e+1)/2<=k   and e<q)e++;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    cout<<100<<endl;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 205

ll i=0,j=0,k=0,cnt1=0,cnt2=0,cnt3=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll arr[101][101];
    memset(arr,0,sizeof(arr));
    ll i=3;
    while(i*(i-1)*(i-2)/6<=k)i++;
    i--;
    k-=i*(i-1)*(i-2)/6;
    ll q=i;
    for(i=1;i<=q;i++)
    {
        for(j=1;j<=q;j++)
        {
            if(i!=j)
                arr[i][j]=1;
        }
    }
    ll cnt=q;
    while(k>0)
    {
        ll e=0;
        while(e*(e-1)/2<=k and e<q)e++;
        if(e<q)
            e--;
        k-=e*(e-1)/2;
        cnt++;
        for(i=1;i<=e;i++)
        {
            arr[i][cnt]=1;
            arr[cnt][i]=1;
        }
    }
    cout<<100<<endl;
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define LL long long
#define mp make_pair
#define fi first
#define se second

int k;
int n;
int arr[105][105];
int C[105];

int check( int x, int y ){
	int ans = 0;
	for ( int z = 1; z <= 100; z++ ){
		if ( arr[x][y] && arr[x][z] && arr[y][z] ) {
			ans++;
		}
	}
	return ans;
}

int main(){

	srand(time(0));

	scanf("%d",&k);
	for ( int i = 3; i <= 100; i++ ){
		C[i] = i * (i-1) * (i-2) / 6;
	}

	int cnt = 0;
	for ( int i = 1; i <= 100; i++ ){
		for ( int j = i + 1; j <= 100; j++ ){
			arr[i][j] = arr[j][i] = 1;
			int tmp = check(i,j);
			if ( cnt + tmp > k ) {
				arr[i][j] = arr[j][i] = 0;
			} else {
				cnt += tmp;
			}
		}
	}

	while ( cnt < k ){
		for ( int i = 1; i <= 100; i++ ){
			for ( int j = i + 1; j <= 100; j++ ){
				if ( arr[i][j] == 0 ) continue;
				int tmp = check(i,j);
				cnt -= tmp;
				arr[i][j] = arr[j][i] = 0;
				for ( int l = 0; l < 100; l++ ){
					int g = rand() % 10000;
					int x = g / 100, y = g % 100;
					x++;
					y++;
					if ( x == y ) continue;
					if ( arr[x][y] == 0 ){
						arr[x][y] = arr[y][x] = 1;
						int tmp = check(x,y);
						if ( cnt + tmp <= k ){
							cnt += tmp;
						} else {
							arr[x][y] = arr[y][x] = 0;
						}
					}
				}
			}
		}
	}
	if ( cnt != k ) assert(1==2);
	n = 100;

	printf("%d\n",n);
	for ( int i = 1; i <= n; i++ ){
		for ( int j = 1; j <= n; j++ ) printf("%d",arr[i][j]);
		printf("\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define LL long long
#define mp make_pair
#define fi first
#define se second

int k;
int n;
int arr[105][105];
int C[105];

int check( int x, int y ){
	int ans = 0;
	for ( int z = 1; z <= 100; z++ ){
		if ( arr[x][y] && arr[x][z] && arr[y][z] ) {
			ans++;
		}
	}
	return ans;
}

int main(){

	srand(time(0));

	scanf("%d",&k);
	for ( int i = 3; i <= 100; i++ ){
		C[i] = i * (i-1) * (i-2) / 6;
	}

	int cnt = 0;
	for ( int i = 1; i <= 100; i++ ){
		for ( int j = i + 1; j <= 100; j++ ){
			arr[i][j] = arr[j][i] = 1;
			int tmp = check(i,j);
			if ( cnt + tmp > k ) {
				arr[i][j] = arr[j][i] = 0;
			} else {
				cnt += tmp;
			}
		}
	}

	while ( cnt < k ){
		for ( int i = 1; i <= 100; i++ ){
			for ( int j = i + 1; j <= 100; j++ ){
				if ( arr[i][j] == 0 ) continue;
				int tmp = check(i,j);
				cnt -= tmp;
				arr[i][j] = arr[j][i] = 0;
				for ( int l = 0; l < 100; l++ ){
					int g = rand() % 10000;
					int x = g / 100, y = g % 100;
					x++;
					y++;
					if ( arr[x][y] == 0 ){
						arr[x][y] = arr[y][x] = 1;
						int tmp = check(x,y);
						if ( cnt + tmp <= k ){
							cnt += tmp;
						} else {
							arr[x][y] = arr[y][x] = 0;
						}
					}
				}
			}
		}
	}
	if ( cnt != k ) assert(1==2);
	n = 100;

	printf("%d\n",n);
	for ( int i = 1; i <= n; i++ ){
		for ( int j = 1; j <= n; j++ ) printf("%d",arr[i][j]);
		printf("\n");
	}
	return 0;
}


#include <iostream>
using namespace std;
int ch(int n, int k){
    if(k == 2){
        if(n == 0 || n == 1) return 0;
        return n * (n - 1)/2;
    }
    if(k == 3){
        if(n == 0 || n == 1 || n == 2) return 0;
        return n * (n - 1) * (n - 2)/6;
    }
    return -1;
}
bool adj[100][100];
int main(){
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < 100; i++){
        if(ch(i,3) <= n){
            x = i;
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < x; j++){
            if(i == j) continue;
            adj[i][j] = true;
        }
    }
    n -= ch(x,3);
    int cur = x;
    while(n != 0){
        int y = 0;
        for(int i = 0; i < 100; i++){
            if(ch(i,2) <= n){
                y = i;
            }
        }
        //Let's add in y
        for(int i = 0; i < y; i++){
            adj[cur][i] = adj[i][cur];
        }
        cur+=y;
        n-=ch(y,2);
    }
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }

}


#include <iostream>
#include <vector>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
bool bad = false;
int chose3(int x){
    return x * (x - 1) * (x - 2)/6;
}
void DFS(int x, int y){
    if(flag) return;
    if(bad) return;
    if(y == 100){
        bad = true;
        return;
    }
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
        cout << 100 << endl;
    if(flag){
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    if(!flag){
        //we have 15 vertices to spare
        vector<int> sz;
        while(soFar < n){
            for(int k = 3; k < 100; k++){
                if(soFar + chose3(k) > n){
                    soFar += chose3(k - 1);
                    sz.push_back(chose3(k-1));
                    break;
                }
            }
        }
        int curPos = 85;
        for(int k = 0; k < sz.size(); k++){
            int sz1 = sz[k];
            for(int i = 0; i < sz1; i++){
                for(int j = 0; j < sz1; j++){
                    adj[curPos + i][curPos + j] = 0;
                }
            }
        }
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }

}


#include <iostream>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
void DFS(int x, int y){
    if(flag) return;
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }
}


#include <iostream>
#include <vector>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
bool bad = false;
int chose3(int x){
    return x * (x - 1) * (x - 2)/6;
}
void DFS(int x, int y){
    if(flag) return;
    if(bad) return;
    if(y == 100){
        bad = true;
        return;
    }
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
        cout << 100 << endl;
    if(!bad){
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    if(bad){
        //we have 15 vertices to spare
        vector<int> sz;
        while(soFar < n){
            for(int k = 3; k < 100; k++){
                if(soFar + chose3(k) > n){
                    soFar += chose3(k - 1);
                    sz.push_back(chose3(k-1));
                    break;
                }
            }
        }
        int curPos = 85;
        for(int k = 0; k < sz.size(); k++){
            int sz1 = sz[k];
            for(int i = 0; i < sz1; i++){
                for(int j = 0; j < sz1; j++){
                    adj[curPos + i][curPos + j] = 0;
                }
            }
        }
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }

}


#include <iostream>
#include <vector>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
bool bad = false;
int chose3(int x){
    return x * (x - 1) * (x - 2)/6;
}
void DFS(int x, int y){
    if(flag) return;
    if(bad) return;
    if(y == 85){
        bad = true;
        return;
    }
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
        cout << 100 << endl;
    if(!bad){
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    if(bad){
        //we have 15 vertices to spare
        vector<int> sz;
        while(soFar < n){
            for(int k = 3; k < 100; k++){
                if(soFar + chose3(k) > n){
                    soFar += chose3(k - 1);
                    sz.push_back(chose3(k-1));
                    break;
                }
            }
        }
        int curPos = 85;
        for(int k = 0; k < sz.size(); k++){
            int sz1 = sz[k];
            for(int i = 0; i < sz1; i++){
                for(int j = 0; j < sz1; j++){
                    adj[curPos + i][curPos + j] = 0;
                }
            }
        }
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }

}


#include <iostream>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
void DFS(int x, int y){
    if(flag) return;
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;
int ch(int n, int k){
    if(k == 2){
        return n * (n - 1)/2;
    }
    if(k == 3){
        return n * (n - 1) * (n - 2)/6;
    }
    return -1;
}
bool adj[100][100];
int main(){
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < 100; i++){
        if(ch(i,3) < n){
            x = i;
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < x; j++){
            if(i == j) continue;
            adj[i][j] = true;
        }
    }
    n -= ch(x,3);
    int cur = x;
    while(n != 0){
        int y = 0;
        for(int i = 0; i < 100; i++){
            if(ch(i,2) <= n){
                y = i;
            }
        }
        //Let's add in y
        for(int i = 0; i < y; i++){
            adj[cur][i] = adj[i][cur];
        }
        cur+=y;
        n-=ch(y,2);
    }
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }

}


#include <iostream>
using namespace std;
int ch(int n, int k){
    if(k == 2){
        return n * (n - 1)/2;
    }
    if(k == 3){
        return n * (n - 1) * (n - 2)/6;
    }
    return -1;
}
bool adj[100][100];
int main(){
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < 100; i++){
        if(ch(i,3) < n){
            x = i;
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < x; j++){
            if(i == j) continue;
            adj[i][j] = true;
        }
    }
    n -= ch(x,3);
    int cur = x;
    while(n != 0){
        int y = 0;
        for(int i = 0; i < 100; i++){
            if(ch(i,2) <= n){
                y = i;
            }
        }
        //Let's add in y
        for(int i = 0; i < y; i++){
            adj[cur][i] = adj[i][cur];
        }
        cur+=y;
        n-=ch(y,2);
    }
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }

}


#include <iostream>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
void DFS(int x, int y){
    if(flag) return;
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }
}


#include <iostream>
#include <vector>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
bool bad = false;
int chose3(int x){
    return x * (x - 1) * (x - 2)/6;
}
void DFS(int x, int y){
    if(flag) return;
    if(bad) return;
    if(y == 85){
        bad = true;
        return;
    }
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
        cout << 100 << endl;
    if(!bad){
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    if(bad){
        //we have 15 vertices to spare
        vector<int> sz;
        while(soFar < n){
            for(int k = 3; k < 100; k++){
                if(soFar + chose3(k) > n){
                    soFar += chose3(k - 1);
                    sz.push_back(chose3(k-1));
                    break;
                }
            }
        }
        int curPos = 85;
        for(int k = 0; k < sz.size(); k++){
            int sz1 = sz[k];
            for(int i = 0; i < sz1; i++){
                for(int j = 0; j < sz1; j++){
                    adj[curPos + i][curPos + j] = 1;
                }
            }
        }
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }

}


#include <iostream>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
void DFS(int x, int y){
    if(flag) return;
    //check if it works
    int cntr = 0;
    for(int i = 0; i < n; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < n){
        DFS(x + 1,y);
    }
    if(x + 1 == n){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;
int ch(int n, int k){
    if(k == 2){
        if(n == 0 || n == 1) return 0;
        return n * (n - 1)/2;
    }
    if(k == 3){
        if(n == 0 || n == 1 || n == 2) return 0;
        return n * (n - 1) * (n - 2)/6;
    }
    return -1;
}
bool adj[100][100];
int main(){
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < 100; i++){
        if(ch(i,3) <= n){
            x = i;
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < x; j++){
            if(i == j) continue;
            adj[i][j] = true;
        }
    }
    n -= ch(x,3);

    int cur = x;
    while(n != 0){
        int y = 0;
        for(int i = 0; i < 100; i++){
            if(ch(i,2) <= n){
                y = i;
            }
        }
        //Let's add in y
        for(int i = 0; i < y; i++){
            adj[cur][i] = adj[i][cur] = 1;
        }
        cur+=y;
        n-=ch(y,2);
    }
    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }

}


#include <iostream>
#include <vector>
#define maxN 100
#define maxK 100000
using namespace std;
int n;
int soFar = 0;
bool adj[maxN][maxN];
bool flag = false;
bool bad = false;
int chose3(int x){
    return x * (x - 1) * (x - 2)/6;
}
void DFS(int x, int y){
    if(flag) return;
    if(bad) return;
    if(y == 85){
        bad = true;
        return;
    }
    if(x == y){
        if(x + 1 < 100){
            DFS(x + 1,y);
        }
        if(x + 1 == 100){
            DFS(0,y + 1);
        }
    }
    //check if it works
    int cntr = 0;
    for(int i = 0; i < 100; i++){
        if(adj[i][y] && adj[i][x]){
            cntr++;
        }
    }
    if(cntr + soFar == n){
        adj[x][y] = adj[y][x] = true;
        flag = true;
        return;
    }
    if(cntr + soFar < n){
        soFar += cntr;
        adj[x][y] = adj[y][x] = true;
    }
    if(x + 1 < 100){
        DFS(x + 1,y);
    }
    if(x + 1 == 100){
        DFS(0,y + 1);
    }
}
int main(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            adj[i][j] = false;
        }
    }
    cin >> n;
    DFS(0,0);
        cout << 100 << endl;
    if(!bad){
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    if(bad){
        //we have 15 vertices to spare
        vector<int> sz;
        while(soFar < n){
            for(int k = 3; k < 100; k++){
                if(soFar + chose3(k) > n){
                    soFar += chose3(k - 1);
                    sz.push_back(chose3(k-1));
                    break;
                }
            }
        }
        int curPos = 85;
        for(int k = 0; k < sz.size(); k++){
            int sz1 = sz[k];
            for(int i = 0; i < sz1; i++){
                for(int j = 0; j < sz1; j++){
                    if(i == j) continue;
                    adj[curPos + i][curPos + j] = 1;
                }
            }
        }
        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                cout << adj[i][j];
            }
            cout << endl;
        }
        return 0;
    }

}


#include <iostream>
using namespace std;
int ch(int n, int k){
    if(k == 2){
        if(n == 0 || n == 1) return 0;
        return n * (n - 1)/2;
    }
    if(k == 3){
        if(n == 0 || n == 1 || n == 2) return 0;
        return n * (n - 1) * (n - 2)/6;
    }
    return -1;
}
bool adj[100][100];
int main(){
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < 100; i++){
        if(ch(i,3) <= n){
            x = i;
        }
    }
    for(int i = 0; i < x; i++){
        for(int j = 0; j < x; j++){
            if(i == j) continue;
            adj[i][j] = true;
        }
    }
    n -= ch(x,3);

    int cur = x;
    while(n != 0){
        int y = 0;
        for(int i = 0; i < 1000; i++){
            if(ch(i,2) <= n){
                y = i;
            }
        }
        //Let's add in y
        for(int i = 0; i < y; i++){
            adj[cur][i] = adj[i][cur] = 1;
        }
        cur++;
        n-=ch(y,2);
    }
    int c = 0;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            for(int k = 0; k < 100; k++){
                if(adj[i][j] && adj[i][k] && adj[j][k]) c++;
            }
        }
        //cout << endl;
    }
    //cout << c << endl;

    cout << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << adj[i][j];
        }
        cout << endl;
    }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long , long long > pl;
const int N=1e6+1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
template< typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll ans1,ans2,ans,mid,mn,mx,cnt,m,T,sum,h1,h2,a,b,c[1<<20],d[1<<20],c1[1234][1234],n,k,i,j,l,x,y,r,z,h,e[1<<20],w;
bool used[10000005];
pl p[1234567];
string s,s1[1234567],ss;
map<ll,ll> mp;
map<pl,ll> mpl;
vl v[1234567];
vl v1,vec;
char cha[1234567];
vector<pl> vp;
int main(){
    cin>>n;
    for(ll i=1;i<=100;i++){
        ll sum=0;
        for(ll j=1;j<i&&n>=sum;j++){
            c1[i][j]=c1[j][i]=1;
            n-=sum;
            sum++;
        }
    }
    cout<<100<<'\n';
    rep(i,1,100){
        rep(j,1,100){
            cout<<c1[i][j];
        }
        cout<<'\n';
    }
}


#include<bits/stdc++.h>
#include<fstream>
#include <iterator>
#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<pair<long long,long long>, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll  long long
#define ull unsigned int
#define ld long double
#define vii vector<int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define se second
#define fi first
#define ins insert
#define _rand(l,r) uniform_ll_distribution<ll>(l, r)(rng)
#define flush() cout.flush()
#define swap(a,b) {ll _temp=a;a=b;b=_temp;}
#define FOR(i,l,r) for(ll i=l;i<=r;++i)
#define FORr(i,r,l) for(ll i=r;i>=l;--i)
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#define MD         1000000007
#define LN      14
#define fftmod      998244353,
#define EPS         (double)1e-10
#define PI          3.14159265358979323846264
#define inf 1e18
#define MAX 100005
#define kill {puts("-1");exit(0);}
ll m=MD;
ll exp(ll a,ll b){ll res = 1LL;while(b){if(b&1){res = res*(a%m);res = (res+m)%m;}b=b>>1;a = (a%m)*(a%m);a  =(a+m)%m;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
bool ans[101][101];
ll nc2(ll i){
	i = i*(i-1);
	return i/2;
}
ll nc3(ll i){
	i = i*(i-1)*(i-2);
	return i/6;
}
int main(){
    IOS;
   	ll k;
   	cin>>k;
   	ll p;
   	for(int i=2;i<=100;i++){
   		if(nc3(i)<=k){
   			p = i;
   		}
   	}
   	k-=nc3(p);
   	for(int i=1;i<=p;i++){
   		for(int j=1;j<=p;j++)
   			if(i!=j)
   				ans[i][j]=1;
   	}
   	while(k){
   		int q=0;
   		for(int i=2;i<=p;i++){
   			if(nc2(i)<=k){
   				q = i;
   			}
   		}
   		k-=nc2(q);
   		p++;
   		for(int i=1;i<=q;i++)
   			ans[i][p]=ans[p][i]=1;
   	}
   	cout<<p<<endl;
   	for(int i=1;i<=p;i++){
   		for(int j=1;j<=p;j++)
   			cout<<ans[i][j];
   		cout<<endl;
   	}
}


/* -*- coding: utf-8 -*-
 *
 * 0232A.cc: A. Cycles
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

bool es[MAX_N + 1][MAX_N + 1];

/* subroutines */

inline int nc2(int n) { return n * (n - 1) / 2; }
inline int nc3(int n) { return n * (n - 1) * (n - 2) / 6; }

void setedges(int i0, int i1) {
  for (int i = i0; i < i1; i++)
    for (int j = i + 1; j < i1; j++)
      es[i][j] = es[j][i] = true;
}

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int k;
  scanf("%d", &k);

  int n = 3;
  while (nc3(n + 1) <= k) n++;
  //printf("n=%d, %dC3=%d\n", n, n, nc3(n));

  setedges(0, n);
  k -= nc3(n);

  while (k > 0) {
    int m = 2;
    while (nc2(m + 1) <= k) m++;
    n++;
    setedges(n - m - 1, n);
    k -= nc2(m);
  }

  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) putchar(es[i][j] ? '1' : '0');
    putchar('\n');
  }
  return 0;
}


/* -*- coding: utf-8 -*-
 *
 * 0232A.cc: A. Cycles
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

bool es[MAX_N + 1][MAX_N + 1];

/* subroutines */

inline int nc3(int n) { return n * (n - 1) * (n - 2) / 6; }

void setedges(int i0, int i1) {
  for (int i = i0; i < i1; i++)
    for (int j = i + 1; j < i1; j++)
      es[i][j] = es[j][i] = true;
}

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int k;
  scanf("%d", &k);

  int n = 3;
  while (nc3(n + 1) <= k) n++;
  //printf("n=%d, %dC3=%d\n", n, n, nc3(n));

  setedges(0, n);
  k -= nc3(n);

  while (k > 0) {
    int m = 3;
    while (nc3(m + 1) <= k) m++;
    n++;
    setedges(n - m, n);
    k -= nc3(m);
  }

  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) putchar(es[i][j] ? '1' : '0');
    putchar('\n');
  }
  return 0;
}


#include "bits/stdc++.h"
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define vi           vector<int>
#define pii          pair<int,int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,(char)y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;

short rain()
{
    // int t;cin>>t;rep(test,1,t)
    {
        int k;
        cin >> k;
        int adj[100][100];
        mem( adj, 0 );
        // Search for the least n,
        // such that (n;3) <= k
        int LO = 3, HI = 85, n = 3;
        while( LO<=HI )
        {
            int M = (LO+HI) >> 1LL;
            if( ( M*(M-1)*(M-2) )/6LL <= k )
                n = M, LO = M+1;
            else
                HI = M-1;
        }
        // cout << n << endl;
        rep(i,0,n-1)
        {
            rep(j,0,n-1)
            {
                if( i==j )
                    continue;
                adj[i][j] = 1;
            }
        }
        k -= (n*(n-1)*(n-2))/6LL;
        int cur = n;
        // cout << k << " " << cur << endl;
        while( k>0 )
        {
            // Search for least m,
            // such that (m-1)*(m-2) / 2 < k
            LO = 3, HI = 85, n = 3;
            while( LO<=HI )
            {
                int M = (LO+HI) >> 1LL;
                if( ( (M-1)*(M-2) )/2LL <= k )
                    n = M, LO = M+1;
                else
                    HI = M-1;
            }
            // add n-1 edges with cur
            rep(i,0,n-2)
            {
                adj[i][cur] = 1;
                adj[cur][i] = 1;
            }
            k -= ( (n-1)*(n-2) )/2LL;
            cur++;
        }
        cout << 100 << endl;
        rep(i,0,99)
        {
            rep(j,0,99)
                cout << adj[i][j];
            cout << endl;
        }
    }

    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    // freopen("ip.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    int tt = 1000*clock()/CLOCKS_PER_SEC;
    cout<<fixed<<setprecision(15);rain();
    cerr<<1000*clock()/CLOCKS_PER_SEC-tt<<"ms\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110;
bool mp[N][N];
int kk,tot;
int main(){
	scanf("%d",&kk);
	int i;
	for (i=1; i*(i-1)*(i-2)/6<=kk; ++i){

	}
	--i;
	for (int j=1; j<=i; ++j)
		for (int k=1; k<=i; ++k)
			if (j!=k)
			mp[j][k]=mp[k][j]=1;
	kk-=i*(i-1)*(i-2)/6;
	int tot=i;
	while (kk){
		for (i=1; i*(i-1)/2<=kk&&i<=tot; ++i);
		--i;
		++tot;
		for (int j=1; j<=i; ++j) mp[j][tot]=mp[tot][j]=1;
		kk-=i*(i-1)/2;
	}
	cout<<tot<<endl;
	for (int i=1; i<=tot; ++i,putchar('\n'))
		for (int j=1; j<=tot; ++j)
			printf("%d",mp[i][j]);
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <map>
#include <deque>
#include <list>
#include <fstream>

using namespace std;

#define pint pair <int, int>
#define F first
#define S second
#define PI 3.141592653589793
#define LL long long
#define RPQ priority_queue<LL, vector<LL>, std::greater<LL> >
#define puf push_front
#define pub push_back
#define pob pop_back
#define pof pop_front
#define MP make_pair
#define mod (LL)(1e5)
#define M int(1e2) * 5

int ary[M][M];

void print() {
	cout << 100 << endl;
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			cout << ary[i][j];
		}
		cout << endl;
	}
}

int main() {
	int k; cin >> k;

	for (int q = 1; q < 50; q++) {
		for (int i = 1; i <= 100; i++) {
			for (int j = i + 2 * q; abs((j % 100) - i) >= q; j++) {
				k--;
				ary[i][i + q] = 1;
				ary[i + q][i] = 1;
				ary[i][j] = 1;
				ary[j][i] = 1;
				ary[j][i + q] = 1;
				ary[i + q][j] = 1;

				if (k == 0) {
					print();
					return 0;
				}
			}
		}
	}

	return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <map>
#include <deque>
#include <list>
#include <fstream>

using namespace std;

#define pint pair <int, int>
#define F first
#define S second
#define PI 3.141592653589793
#define LL long long
#define RPQ priority_queue<LL, vector<LL>, std::greater<LL> >
#define puf push_front
#define pub push_back
#define pob pop_back
#define pof pop_front
#define MP make_pair
#define mod (LL)(1e5)
#define M int(1e2) * 5

#define P 100
int ary[M][M];

void print() {
	cout << P << endl;
	for (int i = 1; i <= P; i++) {
		for (int j = 1; j <= P; j++) {
			cout << ary[i][j];
		}
		cout << endl;
	}
}

int main() {
	int n; cin >> n;

	for (int i = 1; i <= P; i++) {
		for (int j = 1; j < i; j++) {
			int num = 0;
			for (int k = 1; k <= P; k++)
				if (ary[i][k] == 1 && ary[j][k] == 1) num++;

			if (num > n) continue;
			n -= num;
			ary[i][j] = ary[j][i] = 1;
		}
	}
	print();

	return 0;
}


//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//

#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#define pb push_back
#define mk make_pair
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long long ll;
priority_queue <lli, vector<lli>, greater<lli> > q;
vector <lli> p[100] ,b(500005,0);
map <pair<lli,lli>,lli> mp;
lli fact(lli i)
{
    if(i==0)
        return 1;
    lli v=1;
    for(lli j=1;j<=i;j++)
        v*=j;
    return v;
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli k,n;
    cin>>k;
    lli h=2,p=0;
    while(p<=k)
    {
        h++;
        p=fact(h)/(fact(h-3)*fact(3));
    }
    h-=1;
    n=h;
    for(lli i=1;i<=h;i++)
    {
        for(lli j=1;j<=h;j++)
        {
            if(i!=j)
            {
                mp[{i,j}]++;
            }
        }
    }
    p=fact(h)/(fact(h-3)*fact(3));
    lli t=k-p;
    //cout<<t<<endl;
    while(t>0)
    {
        lli f=2;
        while(fact(f)/(fact(f-2)*fact(2))<t)
            f++;
        if(fact(f)/(fact(f-2)*fact(2))>t)
            f--;
        t-=fact(f)/(fact(f-2)*fact(2));
        n++;
        for(lli i=1;i<=f;i++)
        {
            mp[{i,n}]++;
            mp[{n,i}]++;
        }
        //cout<<t<<" "<<f<<endl;
    }
    cout<<n<<endl;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=1;j<=n;j++)
            cout<<mp[{i,j}];
        cout<<endl;
    }
}


//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//

#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#define pb push_back
#define mk make_pair
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long long ll;
priority_queue <lli, vector<lli>, greater<lli> > q;
vector <lli> p[100] ,b(500005,0);
map <pair<lli,lli>,lli> mp;
lli fact(lli i)
{
    if(i==0)
        return 1;
    lli v=1;
    for(lli j=1;j<=i;j++)
        v*=j;
    return v;
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli k,n;
    cin>>k;
    lli h=2,p=0;
    while(p<=k)
    {
        h++;
        p=fact(h)/(fact(h-3)*fact(3));
    }
    h-=1;
    n=h;
    for(lli i=1;i<=h;i++)
    {
        for(lli j=1;j<=h;j++)
        {
            if(i!=j)
            {
                mp[{i,j}]++;
            }
        }
    }
    p=fact(h)/(fact(h-3)*fact(3));
    lli t=k-p;
    cout<<t<<endl;
    while(t>0)
    {
        lli f=2;
        while(fact(f)/(fact(f-2)*fact(2))<t)
            f++;
        if(fact(f)/(fact(f-2)*fact(2))>t)
            f--;
        t-=fact(f)/(fact(f-2)*fact(2));
        n++;
        for(lli i=1;i<=f;i++)
        {
            mp[{i,n}]++;
            mp[{n,i}]++;
        }
        //cout<<t<<" "<<f<<endl;
    }
    cout<<n<<endl;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=1;j<=n;j++)
            cout<<mp[{i,j}];
        cout<<endl;
    }
}


//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//

#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#define pb push_back
#define mk make_pair
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long long ll;
priority_queue <lli, vector<lli>, greater<lli> > q;
vector <lli> p[100] ,b(500005,0);
map <pair<lli,lli>,lli> mp;
lli fact(lli i)
{
    if(i==0)
        return 1;
    lli v=1;
    for(lli j=1;j<=i;j++)
        v*=j;
    return v;
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli k,n;
    cin>>k;
    lli h=2,p=0;
    while(p<=k)
    {
        h++;
        p=((h)*(h-1)*(h-2))/fact(3);
    }
    h-=1;
    n=h;
    for(lli i=1;i<=h;i++)
    {
        for(lli j=1;j<=h;j++)
        {
            if(i!=j)
            {
                mp[{i,j}]++;
            }
        }
    }
    p=((h)*(h-1)*(h-2))/fact(3);
    lli t=k-p;
    //cout<<t<<endl;
    while(t>0)
    {
        lli f=2;
        while((f*(f-1))/2<t)
            f++;
        if((f*(f-1))/2>t)
            f--;
        t-=(f*(f-1))/2;
        n++;
        for(lli i=1;i<=f;i++)
        {
            mp[{i,n}]++;
            mp[{n,i}]++;
        }
        //cout<<t<<" "<<f<<endl;
    }
    cout<<n<<endl;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=1;j<=n;j++)
            cout<<mp[{i,j}];
        cout<<endl;
    }
}


//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//

#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#define pb push_back
#define mk make_pair
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long long ll;
priority_queue <lli, vector<lli>, greater<lli> > q;
vector <lli> p[100] ,b(500005,0);
map <pair<lli,lli>,lli> mp;
lli fact(lli i)
{
    if(i==0)
        return 1;
    lli v=1;
    for(lli j=1;j<=i;j++)
        v*=j;
    return v;
}
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli k,n;
    cin>>k;
    lli h=2,p=0;
    while(p<=k)
    {
        h++;
        p=((h)*(h-1)*(h-2))/fact(3);
    }
    h-=1;
    n=h;
    for(lli i=1;i<=h;i++)
    {
        for(lli j=1;j<=h;j++)
        {
            if(i!=j)
            {
                mp[{i,j}]++;
            }
        }
    }
    p=((h)*(h-1)*(h-2))/fact(3);
    lli t=k-p;
    //cout<<t<<endl;
    while(t>0)
    {
        lli f=2;
        while((f*f-1)/2<t)
            f++;
        if((f*f-1)/2>t)
            f--;
        t-=(f*f-1)/2;
        n++;
        for(lli i=1;i<=f;i++)
        {
            mp[{i,n}]++;
            mp[{n,i}]++;
        }
        //cout<<t<<" "<<f<<endl;
    }
    cout<<n<<endl;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=1;j<=n;j++)
            cout<<mp[{i,j}];
        cout<<endl;
    }
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=1e2+5;
int g[123][123],n,c;
int main(){
     scanf("%d",&n);
     for(int i=0;i<N&&n>0;i++)
     {
          for(int j=0;j<i&&n>0;j++)
          {
               g[i][j]=g[j][i]=1;
               n-=j;
          }
          c++;
     }
     printf("%d\n",c);
     for(int i=0;i<c;i++)
     {
          for(int j=0;j<c;j++)
               printf("%d",g[i][j]);
          printf("\n");
     }
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=1e2+5;
int g[N][N],n,i,j;
#define rep(i,x,y) for(i=x;i<=y;i++)
int main(){
     scanf("%d",&n);
     for( i=1;n;i++)
     {
         int c=-1;
          for( j=1;j<=i-1;j++)
          {
               c++;
               if(n<c)break;
               n-=c;
               g[i][j]=g[j][i]=1;

          }
     }
     printf("%d\n",i-1);
     for(int a=1;a<i;a++)
     {
          for(int b=1;b<i;b++)
               printf("%d",g[a][b]);
          printf("\n");
     }
    return 0;
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=1e2+5;
int g[N][N],n,c;
int main(){
     scanf("%d",&n);
     for(int i=0;i<N&&n>0;i++)
     {
          for(int j=0;j<i&&n>0;j++)
          {
               g[i][j]=g[j][i]=1;
               n-=j;
          }
          c++;
     }
     printf("%d\n",c+1);
     for(int i=0;i<=c;i++)
     {
          for(int j=0;j<=c;j++)
               printf("%d",g[i][j]);
          printf("\n");
     }
    return 0;
}


#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include <vector>
#define ll long long int
#define ve vector<int>
#define vell vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod 998244353
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define check cout<<"s"
#define checkx(x) cout<<x
#define W(x) while(x--)
#define popcount(x) __builtin_popcountll(x)
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;cin>>n;
int ans[101][101];
memset(ans,0,sizeof(ans));
for(int i=2;i<=100;i++)
{
	for(int j=1;j<i;j++)
	{
		if(n>=j-1)
		{
		n-=j-1;
		//cout<<n<<endl;
		ans[i][j]=ans[j][i]=1;
		}
	}
}
cout<<100<<endl;
for(int i=1;i<=100;i++)
{
	for(int j=1;j<=100;j++)
	cout<<ans[i][j];
	cout<<endl;
}

}


#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int total, n = 100, i, j, k, s, ct;
	cin >> total;
	s = 0;
	vector<vector<bool>> conn(n, vector<bool>(n, false));
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			ct = 0;
			for (k = 0; k < n; k++) {
				if ((i != k) && (j != k) && conn[i][k] && conn[k][j]) ct++;
			}
			if (s + ct <= total) {
				s += ct;
				conn[i][j] = true;
				conn[j][i] = true;
			}
		}
	}

	cout << n << "\n";
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (conn[i][j]) cout << "1";
			else cout << "0";
		}
		cout << "\n";
	}

	return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int total, n = 100, i, j, k, s, ct;
	cin >> total;
	s = 0;
	vector<vector<bool>> conn(n, vector<bool>(n, false));
	for (i = 0; i < n; i++) {
		for (j = 0; j < i; j++) {
			ct = 0;
			for (k = 0; k < n; k++) {
				if ((i != k) && (j != k) && conn[i][k] && conn[k][j]) ct++;
			}
			if (s + ct <= total) {
				s += ct;
				conn[i][j] = true;
				conn[j][i] = true;
			}
		}
	}

	cout << n << "\n";
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (conn[i][j]) cout << "1";
			else cout << "0";
		}
		cout << "\n";
	}

	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:200000000")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <map>
#include <memory.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define mset(mas,val) memset(mas,val,sizeof(mas))
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define forn(i,n) for (int i=0; i<int(n); ++i)
#define fornd(i,n) for (int i=int(n)-1; i>=0; --i)
#define forab(i,a,b) for (int i=int(a); i<=int(b); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int INF = (int) 1e9;
const long long INF64 = (long long) 1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
int cur;

bool read() {
	if (!(cin >> cur))
		return false;
	return true;
}
void solve() {
	int n = 100;
	int cnt = 0;
	int d[100][100];
	mset(d, 0);
	forn(i,n)
		for(int j = i+1; j<n; j++)
			for(int k = j + 1; k < n; k++)
	{
		if (cnt < cur)
		{
			d[i][j] = 1;
			d[j][i] = 1;
			d[i][k] = 1;
			d[k][i] = 1;
			d[k][j] = 1;
			d[j][k] = 1;
			cnt++;
		}
	}
	cout << n;
	forn(i,n)
	{
		puts("");
		forn(j,n)
			cout << d[i][j];
	}
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#endif
	while (read())
		solve();
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:200000000")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <map>
#include <memory.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define mset(mas,val) memset(mas,val,sizeof(mas))
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define forn(i,n) for (int i=0; i<int(n); ++i)
#define fornd(i,n) for (int i=int(n)-1; i>=0; --i)
#define forab(i,a,b) for (int i=int(a); i<=int(b); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int INF = (int) 1e9;
const long long INF64 = (long long) 1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
int cur;

bool read() {
	if (!(cin >> cur))
		return false;
	return true;
}
void solve() {
	int n = 100;
	int cnt = 0;
	int d[200][200];
	mset(d, 0);
	int j = 0;
	for(int i=1; ; i++)
		{
			//assert(j <= 100);
			if ((i*(i+1)*(i+2)/6) <= cur && ((i+1)*(i+2)*(i+3)/6) > cur)
			{
				cur -= i*(i+1)*(i+2)/6;
				for(int k=j; k<j+i+2; k++)
				{
					for(int r = k+1; r<j+i+2; r++)
					{
						d[k][r] = 1;
						d[r][k] = 1;
					}
				}
				j += i+2;
				break;
			}
		}
	int f = j;
	while (cur >= 1) {
		int cnt = 0;
		forn(i,f)
		{
			if (cnt*(cnt+1)/2 <= cur) {
				d[i][j] = 1;
				d[j][i] = 1;
				cnt++;
			} else {
				j++;
				break;
			}
		}
		cur -= cnt*(cnt-1)/2;
	}
	assert(j <= 100);
	cout << n;
	forn(i,n)
	{
		puts("");
		forn(j,n)
			cout << d[i][j];
	}
}
void check () {

}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#endif
	while (read())
		solve();
	check();
}


#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:200000000")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <map>
#include <memory.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define mset(mas,val) memset(mas,val,sizeof(mas))
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define forn(i,n) for (int i=0; i<int(n); ++i)
#define fornd(i,n) for (int i=int(n)-1; i>=0; --i)
#define forab(i,a,b) for (int i=int(a); i<=int(b); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int INF = (int) 1e9;
const long long INF64 = (long long) 1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
int k;

bool read() {
	if (!(cin >> k))
		return false;
	return true;
}
void solve() {
	int n = 100;
	int cnt = 0;
	int d[100][100];
	mset(d, 0);
	forn(i,n)
		for(int j = i+1; j<n; j++)
			for(int k = j + 1; k < n; k++)
	{
		if (cnt < k)
		{
			d[i][j] = 1;
			d[j][i] = 1;
			d[i][k] = 1;
			d[k][i] = 1;
			d[k][j] = 1;
			d[j][k] = 1;
			cnt++;
		}
	}
	cout << n;
	forn(i,n)
	{
		puts("");
		forn(j,n)
			cout << d[i][j];
	}
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#endif
	while (read())
		solve();
}


import javax.swing.event.TreeSelectionEvent;

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

public class Main {
    static long gcd(long a, long b) {
        return a == 0 ? b : gcd(b, b % a);
    }

    static long binpow(long a, int n) {
        return n == 1 ? a : (n & 1) == 0 ? binpow(a, n / 2) * binpow(a, n / 2) : a * binpow(a, n - 1);
    }

    static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    static ArrayList<Integer> g[];
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        // FastScanner in = new FastScanner("search.in");
        //PrintWriter out = new PrintWriter("search.out");
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            g = new ArrayList[n];
            for (int i = 0; i < n; i++)
                g[i] = new ArrayList<>();
            for (int i = 0; i < m; i++) {
                int v = in.nextInt() - 1;
                int u = in.nextInt() - 1;
                g[v].add(u);
                g[u].add(v);
            }
            Queue<Integer> bfs = new ArrayDeque<>();
            int dist[] = new int[n];
            for (int i = 1; i < n; i++) {
                dist[i] = -1;
            }
            bfs.add(0);
            while (!bfs.isEmpty()) {
                int v = bfs.poll();
                for (Integer to : g[v])
                    if (dist[to] == -1) {
                        dist[to] = dist[v] + 1;
                        bfs.add(to);
                    }
            }
            int sum[] = new int[2];
            for (int i = 0; i < n; i++) {
                sum[dist[i] & 1]++;
            }
            int ans = 0;
            if(sum[0] == sum[1]){
                for (int i = 0; i < n; i++) {
                    if((i&1)==0)ans++;
                }
                out.println(ans);
                for (int i = 0; i < n; i++) {
                    if((i & 1) == 0)out.print(i+1+" ");
                }
                out.println();
                continue;
            }
            for (int i = 0; i < n; i++) {
                if (sum[dist[i] & 1] < sum[(dist[i] + 1) & 1]) ans++;
            }
            out.println(ans);
            for (int i = 0; i < n; i++) {
                if (sum[dist[i] & 1] < sum[(dist[i] + 1) & 1]) out.print(i + 1 + " ");
            }
            out.println();
        }
        out.close();
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    public FastScanner(InputStream s) {
        br = new BufferedReader(new InputStreamReader(s));
    }

    public FastScanner(String s) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(new File(s)));
    }

    public String next() throws IOException {
        if (!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}