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

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

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

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

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

m.o = l
c.t = k
l.w = m
k.y = m
k.o = m
k.v = c
k.w = c
assert k.o.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

m.o = l
c.t = k
l.w = m
k.y = m
k.o = m
k.v = c
k.w = c
assert k.o.o.w.txt == "m"