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

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

l = A("l")
m = B("m")
b = B("b")
j = A("j")
n = B("n")
g = A("g")
f = B("f")
i = A("i")
d = A("d")
e = A("e")

l.u = e
m.o = d
m.q = e
b.o = g
b.q = g
j.u = i
n.o = d
n.q = l
g.u = e
f.o = i
f.q = j
i.u = g
d.u = j
e.u = l
assert l.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
b = B("b")
j = A("j")
n = B("n")
g = A("g")
f = B("f")
i = A("i")
d = A("d")
e = A("e")

l.u = e
m.o = d
m.q = e
b.o = g
b.q = g
j.u = i
n.o = d
n.q = l
g.u = e
f.o = i
f.q = j
i.u = g
d.u = j
e.u = l
assert l.u.u.u.u.u.u.u.u.txt == "l"