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

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

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

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

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

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

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

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

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

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

a.q = c
a.x = c
a.z = c
a.p = n
i.x = n
i.s = a
i.q = l
i.u = c
n.y = a
c.u = a
c.o = i
c.r = n
j.x = l
j.q = l
j.s = a
j.u = c
l.y = a
assert j.x.y.p.txt == "n"