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

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

n = A("n")
b = B("b")
f = A("f")
a = A("a")
h = B("h")
c = B("c")
g = A("g")
i = A("i")
l = B("l")
e = A("e")

n.r = a
b.u = l
f.r = g
a.r = g
h.u = b
c.u = h
g.r = e
i.r = e
l.u = h
e.r = i
assert l.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

n = A("n")
b = B("b")
f = A("f")
a = A("a")
h = B("h")
c = B("c")
g = A("g")
i = A("i")
l = B("l")
e = A("e")

n.r = a
b.u = l
f.r = g
a.r = g
h.u = b
c.u = h
g.r = e
i.r = e
l.u = h
e.r = i
assert l.u.u.u.u.u.txt == "b"