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

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

b = A("b")
e = B("e")
g = B("g")
h = A("h")

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

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

b = A("b")
e = B("e")
g = B("g")
h = A("h")

b.u = e
b.o = h
e.z = h
e.u = b
g.z = h
g.u = h
h.u = e
h.o = b
assert b.u.z.u.txt == "e"