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

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

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

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

f = A("f")
b = B("b")
m = C("m")
i = D("i")

f.z = i
b.w = i
m.y = b
m.v = f
m.t = f
i.v = m
assert i.v.y.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
m = C("m")
i = D("i")

f.z = i
b.w = i
m.y = b
m.v = f
m.t = f
i.v = m
assert i.v.y.w.v.txt == "m"