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

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

n = A("n")
a = B("a")
j = B("j")
h = B("h")
e = B("e")
m = B("m")
f = B("f")
g = B("g")
l = B("l")
d = A("d")

n.o = j
a.r = d
a.o = f
j.r = d
j.o = f
h.r = n
h.o = a
e.r = n
e.o = m
m.r = n
m.o = g
f.r = d
f.o = g
g.r = n
g.o = j
l.r = n
l.o = e
d.o = l
assert j.r.o.o.o.o.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

n = A("n")
a = B("a")
j = B("j")
h = B("h")
e = B("e")
m = B("m")
f = B("f")
g = B("g")
l = B("l")
d = A("d")

n.o = j
a.r = d
a.o = f
j.r = d
j.o = f
h.r = n
h.o = a
e.r = n
e.o = m
m.r = n
m.o = g
f.r = d
f.o = g
g.r = n
g.o = j
l.r = n
l.o = e
d.o = l
assert j.r.o.o.o.o.o.r.o.txt == "l"