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

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

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

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

n = A("n")
j = B("j")
g = C("g")
e = D("e")
k = B("k")
b = D("b")

n.q = g
n.p = b
j.t = g
g.x = e
e.z = g
e.w = g
e.u = b
k.t = g
b.z = g
b.w = g
b.u = e
assert e.z.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: D = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
g = C("g")
e = D("e")
k = B("k")
b = D("b")

n.q = g
n.p = b
j.t = g
g.x = e
e.z = g
e.w = g
e.u = b
k.t = g
b.z = g
b.w = g
b.u = e
assert e.z.x.u.txt == "b"