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

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

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

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

b = A("b")
m = B("m")
k = C("k")
c = D("c")
n = C("n")

b.t = c
m.r = n
k.w = m
c.s = k
c.v = m
c.z = n
n.w = m
assert n.w.r.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
k = C("k")
c = D("c")
n = C("n")

b.t = c
m.r = n
k.w = m
c.s = k
c.v = m
c.z = n
n.w = m
assert n.w.r.w.r.w.txt == "m"