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

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

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

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

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

f.v = m
f.w = m
f.z = g
h.y = m
h.v = g
m.w = f
m.y = f
m.s = h
g.s = h
g.u = f
g.z = m
i.y = m
i.v = g
assert h.y.w.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

f.v = m
f.w = m
f.z = g
h.y = m
h.v = g
m.w = f
m.y = f
m.s = h
g.s = h
g.u = f
g.z = m
i.y = m
i.v = g
assert h.y.w.z.s.txt == "h"