class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: D = 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.t: A = None
        self.txt = txt

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

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

b.z = e
b.t = e
l.o = e
c.t = b
e.z = b
e.s = b
e.q = l
assert b.z.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: D = 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.t: A = None
        self.txt = txt

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

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

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