#include <iostream>
#include <map>
#include <cassert>
#include <vector>
#include <set>

#define Assert(ex) assert(test_name.c_str() && (ex))
#define TEST(title) test_name = (title);

#include "func.h"

char RndLetter() {
    return (rand() % 26) + 'a';
}

int RndInt(int l, int r) {
    return (rand() % (r - l + 1)) + l;
}

int main() {
    int test; std::cin >> test;
    std::string test_name;
    srand(test);
    
    TEST("not serializable") {
        std::set<int> not_working;
        not_working.insert(1);
        not_working.insert(2);
        not_working.insert(2);
        Assert(Serialize(not_working) == "");
    }
    
    TEST("string serialize") {
        std::string name = "Dasha";
        Assert(Serialize(name) == "\"Dasha\"");
    }
    
    std::vector<std::string> names;
    TEST("random strings") {
        int q = (test == 0 ? 10 : 100);
        for (size_t i = 0; i < q; ++i) {
            int size = (rand() % 7) + 5;
            std::string name(size, '\0');
            for (size_t j = 0; j < size; ++j) {
                name[j] = RndLetter();
            }
            Assert(Serialize(name) == "\"" + name + "\"");
            names.push_back(name);
        }
    }
    
    TEST("vector check") {
        std::vector<int> numbers = {1, 2, 3};
        Assert(Serialize(numbers) == "[1,2,3]");
        
        std::vector<std::string> strings = {"a", "bb", "ccc"};
        Assert(Serialize(strings) == "[\"a\",\"bb\",\"ccc\"]");
        
        std::vector<int> empty;
        Assert(Serialize(empty) == "[]");
    }
    
    TEST("map check") {
        std::map<int, std::string> test_map = {{1, "one"}, {2, "two"}};
        Assert(Serialize(test_map) == "{1:\"one\",2:\"two\"}");
        
        std::map<std::string, int> string_keys = {{"a", 1}, {"b", 2}};
        Assert(Serialize(string_keys) == "{\"a\":1,\"b\":2}");
        
        std::map<int, int> empty_map;
        Assert(Serialize(empty_map) == "{}");
    }
    
    TEST("nested structures") {
        std::vector<std::map<int, std::string>> nested = {
            {{1, "a"}, {2, "b"}},
            {{3, "c"}, {4, "d"}}
        };
        // std::cout << Serialize(nested) << '\n';
        Assert(Serialize(nested) == "[{1:\"a\",2:\"b\"},{3:\"c\",4:\"d\"}]");
        
        std::map<std::string, std::vector<int>> map_with_vectors = {
            {"odds", {1, 3, 5}},
            {"evens", {2, 4, 6}}
        };
        Assert(Serialize(map_with_vectors) == "{\"evens\":[2,4,6],\"odds\":[1,3,5]}");
    }
    
    TEST("int serialize") {
        Assert(Serialize(42) == "42");
        Assert(Serialize(-10) == "-10");
        Assert(Serialize(0) == "0");
    }
    
    TEST("empty collections") {
        std::vector<int> empty_vec;
        std::map<int, int> empty_map;
        std::vector<std::map<int, int>> empty_nested;
        
        Assert(Serialize(empty_vec) == "[]");
        Assert(Serialize(empty_map) == "{}");
        Assert(Serialize(empty_nested) == "[]");
    }
    
    TEST("single element collections") {
        std::vector<int> single = {42};
        std::map<int, std::string> single_map = {{1, "one"}};
        
        Assert(Serialize(single) == "[42]");
        Assert(Serialize(single_map) == "{1:\"one\"}");
    }

    std::cout << "All tests passed!" << std::endl;
    return 0;
}