class A:
    def __init__(self, txt: str):
        self.w: D = 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.t: D = None
        self.w: D = None
        self.txt = txt

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

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

j.w = h
l.w = m
m.t = h
m.w = h
h.w = m
h.t = j
assert h.w.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = 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.t: D = None
        self.w: D = None
        self.txt = txt

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

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

j.w = h
l.w = m
m.t = h
m.w = h
h.w = m
h.t = j
assert h.w.t.t.txt == "j"