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

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

d = A("d")
h = B("h")
j = B("j")
l = A("l")
a = A("a")

d.z = l
d.o = a
h.v = j
h.s = j
j.v = h
j.s = h
l.z = a
l.o = d
a.z = l
a.o = l
assert h.v.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: A = None
        self.txt = txt

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

d = A("d")
h = B("h")
j = B("j")
l = A("l")
a = A("a")

d.z = l
d.o = a
h.v = j
h.s = j
j.v = h
j.s = h
l.z = a
l.o = d
a.z = l
a.o = l
assert h.v.s.s.txt == "j"