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

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

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

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

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

m.q = j
m.s = l
m.x = l
m.r = l
j.u = m
j.p = f
l.s = m
l.u = j
f.q = l
f.z = j
b.q = l
b.z = j
assert l.s.q.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.x: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

m.q = j
m.s = l
m.x = l
m.r = l
j.u = m
j.p = f
l.s = m
l.u = j
f.q = l
f.z = j
b.q = l
b.z = j
assert l.s.q.p.z.txt == "j"