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

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

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

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

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

i.w = m
j.v = i
m.z = i
h.o = i
assert h.o.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

i.w = m
j.v = i
m.z = i
h.o = i
assert h.o.w.z.w.txt == "m"