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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
f = D("f")
h = A("h")
c = C("c")

d.t = c
k.z = d
m.z = d
m.s = c
m.y = c
m.o = k
f.z = m
h.t = m
c.z = d
c.s = m
c.y = m
c.o = k
assert m.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
f = D("f")
h = A("h")
c = C("c")

d.t = c
k.z = d
m.z = d
m.s = c
m.y = c
m.o = k
f.z = m
h.t = m
c.z = d
c.s = m
c.y = m
c.o = k
assert m.z.t.z.t.txt == "c"