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

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

h = A("h")
b = B("b")
a = B("a")
n = A("n")
i = B("i")

h.o = i
b.z = n
b.u = n
a.z = n
a.u = h
n.o = i
i.z = n
i.u = h
assert h.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

h = A("h")
b = B("b")
a = B("a")
n = A("n")
i = B("i")

h.o = i
b.z = n
b.u = n
a.z = n
a.u = h
n.o = i
i.z = n
i.u = h
assert h.o.u.o.u.txt == "h"