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

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

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

c = A("c")
e = B("e")
n = C("n")
b = A("b")
d = A("d")
m = C("m")
l = A("l")
k = B("k")
i = B("i")

c.s = l
e.y = c
e.q = k
n.u = k
b.s = d
d.s = b
m.u = k
l.s = b
k.y = d
k.q = e
i.y = b
i.q = e
assert b.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
n = C("n")
b = A("b")
d = A("d")
m = C("m")
l = A("l")
k = B("k")
i = B("i")

c.s = l
e.y = c
e.q = k
n.u = k
b.s = d
d.s = b
m.u = k
l.s = b
k.y = d
k.q = e
i.y = b
i.q = e
assert b.s.s.s.s.s.s.txt == "b"