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

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

c = A("c")
e = B("e")
m = C("m")
k = D("k")

c.y = e
c.w = k
e.w = m
m.y = k
k.o = m
k.w = c
assert m.y.o.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        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.y: D = None
        self.txt = txt

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

c = A("c")
e = B("e")
m = C("m")
k = D("k")

c.y = e
c.w = k
e.w = m
m.y = k
k.o = m
k.w = c
assert m.y.o.y.w.txt == "c"