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

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

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

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

c = A("c")
b = B("b")
d = C("d")
m = D("m")

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

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

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

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

c = A("c")
b = B("b")
d = C("d")
m = D("m")

c.y = m
b.t = d
d.z = m
d.t = c
m.w = d
m.t = d
assert d.t.y.w.txt == "d"