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

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

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

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

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

l.p = e
l.x = e
l.o = c
e.u = b
e.t = b
e.z = l
e.r = l
b.r = l
c.s = e
c.p = e
assert l.o.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

l.p = e
l.x = e
l.o = c
e.u = b
e.t = b
e.z = l
e.r = l
b.r = l
c.s = e
c.p = e
assert l.o.p.t.txt == "b"