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

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

l = A("l")
b = B("b")
c = B("c")
d = A("d")
n = B("n")
g = A("g")
e = B("e")
f = A("f")

l.s = n
b.u = c
c.u = n
d.s = e
n.u = e
g.s = b
e.u = c
f.s = c
assert c.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
c = B("c")
d = A("d")
n = B("n")
g = A("g")
e = B("e")
f = A("f")

l.s = n
b.u = c
c.u = n
d.s = e
n.u = e
g.s = b
e.u = c
f.s = c
assert c.u.u.u.u.u.txt == "e"