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

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

a = A("a")
h = B("h")
k = B("k")
j = A("j")
g = B("g")
b = A("b")
i = B("i")
l = A("l")
c = A("c")
n = A("n")

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

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

a = A("a")
h = B("h")
k = B("k")
j = A("j")
g = B("g")
b = A("b")
i = B("i")
l = A("l")
c = A("c")
n = A("n")

a.o = j
h.r = a
k.r = l
j.o = c
g.r = n
b.o = n
i.r = a
l.o = c
c.o = j
n.o = b
assert l.o.o.o.o.o.o.txt == "j"