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

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

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

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

b = A("b")
n = B("n")
i = C("i")
d = D("d")
a = B("a")
c = C("c")

b.z = n
b.t = d
n.t = a
i.w = n
i.x = a
i.o = a
d.w = a
a.t = n
c.w = n
c.x = n
c.o = n
assert n.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: D = None
        self.txt = txt

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

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

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

b = A("b")
n = B("n")
i = C("i")
d = D("d")
a = B("a")
c = C("c")

b.z = n
b.t = d
n.t = a
i.w = n
i.x = a
i.o = a
d.w = a
a.t = n
c.w = n
c.x = n
c.o = n
assert n.t.t.t.t.txt == "n"