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

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

e = A("e")
h = B("h")
a = A("a")
c = B("c")
f = B("f")
m = A("m")
b = B("b")
n = B("n")
d = A("d")

e.u = n
h.u = f
h.o = d
a.u = h
c.u = n
c.o = d
f.u = b
f.o = a
m.u = h
b.u = n
b.o = d
n.u = h
n.o = e
d.u = f
assert b.o.u.u.u.u.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
a = A("a")
c = B("c")
f = B("f")
m = A("m")
b = B("b")
n = B("n")
d = A("d")

e.u = n
h.u = f
h.o = d
a.u = h
c.u = n
c.o = d
f.u = b
f.o = a
m.u = h
b.u = n
b.o = d
n.u = h
n.o = e
d.u = f
assert b.o.u.u.u.u.o.u.o.u.txt == "h"