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

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

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

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

k = A("k")
g = B("g")
e = C("e")
n = D("n")

k.o = n
g.x = n
g.u = k
g.z = k
g.t = e
e.w = n
n.z = e
assert e.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
e = C("e")
n = D("n")

k.o = n
g.x = n
g.u = k
g.z = k
g.t = e
e.w = n
n.z = e
assert e.w.z.w.txt == "n"