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

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

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

e.u = c
e.o = c
h.u = a
c.u = e
c.o = e
a.u = h
assert a.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

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

e.u = c
e.o = c
h.u = a
c.u = e
c.o = e
a.u = h
assert a.u.u.u.u.txt == "a"