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

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

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

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

c = A("c")
d = B("d")
f = C("f")
i = D("i")
h = C("h")
m = B("m")

c.w = m
c.y = d
d.s = h
f.v = h
f.w = h
f.y = d
f.z = c
i.o = d
h.v = f
h.w = f
h.y = m
h.z = c
m.s = f
assert m.s.w.y.s.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
f = C("f")
i = D("i")
h = C("h")
m = B("m")

c.w = m
c.y = d
d.s = h
f.v = h
f.w = h
f.y = d
f.z = c
i.o = d
h.v = f
h.w = f
h.y = m
h.z = c
m.s = f
assert m.s.w.y.s.z.w.txt == "m"