#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using std::string;
using std::cout;
using std::cin;
using std::vector;
using std::endl;

class Object {
 public:
    virtual string ToString() const = 0;

    virtual ~Object() = default;
};

class Apple : public Object {
 public:
    string ToString() const override {
        return "apple!";
    }
};

class List : public Object {
 public:
    string ToString() const override {
        return "list";
    }
};

class YetAnotherId : public Object {
 public:
    string ToString() const override {
        return "yet another identifier";
    }
};

class Smth : public Object {
 public:
    explicit Smth(const string &id) {
        class_id_ = id;
    }

    string ToString() const override {
        return class_id_;
    }

 private:
    string class_id_;
};

Object *my_new_smth_() {
    return new Smth(class_id);
}

class Factory {
 public:
    static Object *Create(const string &id) {
        if (id == "apple") {
            return new Apple;
        } else if (id == "list") {
            return new List;
        } else if (id == "yet another identifier") {
            return new YetAnotherId;
        } else {
            return my_new_smth_();
        }
    }
    static void Register(const string &id, Object *(*instance_creator)()) {
    }
};