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

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

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

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

n = A("n")
j = B("j")
d = C("d")
e = D("e")

n.w = d
n.u = d
j.w = e
j.r = d
d.y = e
d.s = e
e.z = j
e.t = j
e.y = j
assert d.s.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: C = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
d = C("d")
e = D("e")

n.w = d
n.u = d
j.w = e
j.r = d
d.y = e
d.s = e
e.z = j
e.t = j
e.y = j
assert d.s.z.r.txt == "d"