rewrite code to allow bigger sizes and for each thread to recover solution, which are printed on single line now