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

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

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

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

f = A("f")
h = B("h")
l = C("l")
j = D("j")

f.t = h
h.o = j
l.u = h
l.w = f
j.z = h
j.o = h
j.s = l
j.x = l
assert h.o.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
l = C("l")
j = D("j")

f.t = h
h.o = j
l.u = h
l.w = f
j.z = h
j.o = h
j.s = l
j.x = l
assert h.o.x.u.txt == "h"