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

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

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

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

a = A("a")
j = B("j")
d = C("d")
m = D("m")

a.s = m
j.v = d
d.t = a
d.v = a
m.z = d
assert m.z.t.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
d = C("d")
m = D("m")

a.s = m
j.v = d
d.t = a
d.v = a
m.z = d
assert m.z.t.s.z.txt == "d"