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

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

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

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

h = A("h")
b = B("b")
i = C("i")
e = D("e")
m = A("m")
a = B("a")
l = B("l")

h.z = i
h.x = i
h.w = b
b.x = e
b.y = h
i.z = e
i.s = e
e.v = l
m.z = i
m.x = i
m.w = l
a.x = e
a.y = h
l.x = e
l.y = m
assert a.x.v.x.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.w: B = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
i = C("i")
e = D("e")
m = A("m")
a = B("a")
l = B("l")

h.z = i
h.x = i
h.w = b
b.x = e
b.y = h
i.z = e
i.s = e
e.v = l
m.z = i
m.x = i
m.w = l
a.x = e
a.y = h
l.x = e
l.y = m
assert a.x.v.x.v.y.txt == "m"