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

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

h = A("h")
e = B("e")
a = A("a")
l = B("l")

h.z = a
h.v = a
e.w = h
a.z = h
a.v = h
l.w = h
assert a.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
a = A("a")
l = B("l")

h.z = a
h.v = a
e.w = h
a.z = h
a.v = h
l.w = h
assert a.v.z.v.txt == "h"