import random
random.seed("something")

class TestGen:
    def __init__(self):
        self.test_number = 0

    def generate_samples(self):
        self.print_test(0, 10)
        self.print_test(10000, 100000)
        
    def generate_min_tests(self):
        self.print_test(0, 0)
        self.print_test(0, 1)
        self.print_test(0, 5)
        self.print_test(1, 1)
        self.print_test(1, 2)
        self.print_test(2, 2)
        self.print_test(100, 500)
        self.print_test(500, 500)
                                                                    
    def generate_hand_tests(self):
        self.print_test(1, 36000)
        self.print_test(36000, 36000)
        self.print_test(35999, 35999)
        self.print_test(36000 * 2**6, 36000 * 2**6)
        self.print_test(36000 * 2**6 - 1, 36000 * 2**6 - 1)
        self.print_test(36000 * 2**6 + 1, 36000 * 2**6 + 1)
        self.print_test(36000 * 2**6 - 1, 36000 * 2**6 + 1)
        self.print_test(999074767124736000, 999074767124736000)
        self.print_test(999074767124736000 - 1, 999074767124736000 - 1)
        self.print_test(999074767124736000 + 1, 999074767124736000 + 1)

    def generate_random_test(self, maxn):
        l = random.randint(1, 174)
        r = random.randint(l, 174)
        l = 36000 * l**6
        r = 36000 * r**6
        l -= random.randint(0, l)
        r += random.randint(0, maxn - r)
        self.print_test(l, r)

    def generate_max_tests(self, maxn):
        self.print_test(0, 10**18)
        self.print_test(1, 10**18)
        self.print_test(10**18, 10**18)
        self.print_test(0, 999074767124736000)
        self.print_test(0, 999074767124736000 - 1)
        self.print_test(0, 999074767124736000 + 1)
        self.print_test(1, 999074767124736000)
        self.print_test(1, 999074767124736000 - 1)
        self.print_test(1, 999074767124736000 + 1)
        self.print_test(999074767124736000 - 1, 10**18)
        self.print_test(999074767124736000, 10**18)
        self.print_test(999074767124736000 + 1, 10**18)

    def print_test(self, l, r):
        self.test_number += 1
        test_name = "../tests/" + "{0:0=2d}".format(self.test_number)
        test_file = open(test_name, "w")
        print(l, r, file=test_file)
        test_file.close()

    def generate_all_tests(self):
        maxn = 10**18

        self.generate_samples()
        self.generate_hand_tests()
        self.generate_min_tests()
        
        for i in range(20):
            self.generate_random_test(maxn)
        self.generate_max_tests(maxn)        

import os, shutil
if os.path.exists('../tests'):
    print('Directory tests is already exists')
    shutil.rmtree('../tests', ignore_errors=False, onerror=None)
try:
    os.makedirs('../tests')
except OSError:
    pass

import time
start = time.time()
writer = TestGen()
writer.generate_all_tests()
finish = time.time()
print('All tests were generated. Elapsed time: ', finish - start)