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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.txt = txt

g = A("g")
b = B("b")
m = C("m")
l = D("l")

g.q = m
g.p = l
g.z = b
b.t = l
m.s = l
m.z = b
l.v = m
l.w = m
assert b.t.w.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: D = None
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.txt = txt

g = A("g")
b = B("b")
m = C("m")
l = D("l")

g.q = m
g.p = l
g.z = b
b.t = l
m.s = l
m.z = b
l.v = m
l.w = m
assert b.t.w.z.t.txt == "l"