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

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

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

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

l = A("l")
j = B("j")
m = C("m")
f = D("f")

l.w = j
l.z = j
l.t = f
j.w = m
m.r = j
f.v = m
f.t = m
assert f.v.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: D = None
        self.z: B = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
m = C("m")
f = D("f")

l.w = j
l.z = j
l.t = f
j.w = m
m.r = j
f.v = m
f.t = m
assert f.v.r.w.txt == "m"