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

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

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

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

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

b.w = n
b.x = n
m.s = b
m.u = j
m.t = n
a.p = j
a.x = m
a.u = m
n.z = j
n.y = m
j.s = b
j.u = m
j.t = n
assert j.u.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

b.w = n
b.x = n
m.s = b
m.u = j
m.t = n
a.p = j
a.x = m
a.u = m
n.z = j
n.y = m
j.s = b
j.u = m
j.t = n
assert j.u.s.x.txt == "n"