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

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

l = A("l")
n = B("n")
d = A("d")
i = A("i")
k = A("k")
a = B("a")
e = B("e")
g = A("g")
c = A("c")

l.r = a
l.x = e
n.u = a
d.r = e
d.x = e
i.r = e
i.x = a
k.r = a
k.x = n
a.u = e
e.u = n
g.r = a
g.x = a
c.r = a
c.x = e
assert a.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: B = None
        self.txt = txt

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

l = A("l")
n = B("n")
d = A("d")
i = A("i")
k = A("k")
a = B("a")
e = B("e")
g = A("g")
c = A("c")

l.r = a
l.x = e
n.u = a
d.r = e
d.x = e
i.r = e
i.x = a
k.r = a
k.x = n
a.u = e
e.u = n
g.r = a
g.x = a
c.r = a
c.x = e
assert a.u.u.u.u.u.u.txt == "a"