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

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

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

m = A("m")
f = B("f")
i = C("i")
a = A("a")
h = C("h")
c = A("c")

m.o = h
f.w = i
f.r = i
i.v = h
i.x = h
i.o = m
a.o = i
h.v = i
h.x = i
h.o = m
c.o = i
assert h.o.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
i = C("i")
a = A("a")
h = C("h")
c = A("c")

m.o = h
f.w = i
f.r = i
i.v = h
i.x = h
i.o = m
a.o = i
h.v = i
h.x = i
h.o = m
c.o = i
assert h.o.o.x.txt == "i"