class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
h = B("h")
i = C("i")

m.v = i
h.v = i
h.w = i
h.t = m
i.o = h
assert m.v.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
h = B("h")
i = C("i")

m.v = i
h.v = i
h.w = i
h.t = m
i.o = h
assert m.v.o.t.txt == "m"