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

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

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

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

l = A("l")
b = B("b")
c = C("c")
h = D("h")
e = D("e")

l.z = c
l.u = b
b.s = e
c.s = l
c.u = l
h.o = l
h.q = c
e.o = l
e.q = c
assert h.o.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: B = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
c = C("c")
h = D("h")
e = D("e")

l.z = c
l.u = b
b.s = e
c.s = l
c.u = l
h.o = l
h.q = c
e.o = l
e.q = c
assert h.o.z.s.txt == "l"