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

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

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

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

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

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

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