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

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

e = A("e")
l = B("l")
k = B("k")
f = B("f")
j = A("j")
a = A("a")
h = A("h")

e.r = k
l.u = f
k.u = f
f.u = l
j.r = l
a.r = l
h.r = l
assert h.r.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
k = B("k")
f = B("f")
j = A("j")
a = A("a")
h = A("h")

e.r = k
l.u = f
k.u = f
f.u = l
j.r = l
a.r = l
h.r = l
assert h.r.u.u.u.u.u.u.txt == "l"