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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: C = None
        self.t: D = None
        self.u: C = None
        self.txt = txt

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

m = A("m")
b = B("b")
j = C("j")
l = D("l")
a = C("a")

m.r = l
m.q = l
m.z = b
b.q = m
b.x = j
j.q = l
j.t = l
j.z = a
j.u = a
l.s = m
l.q = m
l.w = b
l.r = j
a.q = l
a.t = l
a.z = j
a.u = j
assert l.w.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: B = None
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: C = None
        self.t: D = None
        self.u: C = None
        self.txt = txt

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

m = A("m")
b = B("b")
j = C("j")
l = D("l")
a = C("a")

m.r = l
m.q = l
m.z = b
b.q = m
b.x = j
j.q = l
j.t = l
j.z = a
j.u = a
l.s = m
l.q = m
l.w = b
l.r = j
a.q = l
a.t = l
a.z = j
a.u = j
assert l.w.q.z.q.z.txt == "b"