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

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

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

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

a = A("a")
e = B("e")
l = C("l")
n = D("n")
c = D("c")

a.x = n
e.r = l
e.o = l
e.p = l
e.q = a
l.z = a
l.t = e
l.r = e
l.y = c
n.s = e
c.s = e
assert l.y.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
l = C("l")
n = D("n")
c = D("c")

a.x = n
e.r = l
e.o = l
e.p = l
e.q = a
l.z = a
l.t = e
l.r = e
l.y = c
n.s = e
c.s = e
assert l.y.s.q.txt == "a"