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

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

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

g = A("g")
e = B("e")
d = C("d")
l = C("l")
n = C("n")
h = C("h")
a = B("a")
c = C("c")
b = C("b")
m = A("m")

g.s = l
e.s = l
d.y = m
l.y = m
n.y = g
h.y = g
a.s = n
c.y = m
b.y = g
m.s = n
assert c.y.s.y.s.y.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
d = C("d")
l = C("l")
n = C("n")
h = C("h")
a = B("a")
c = C("c")
b = C("b")
m = A("m")

g.s = l
e.s = l
d.y = m
l.y = m
n.y = g
h.y = g
a.s = n
c.y = m
b.y = g
m.s = n
assert c.y.s.y.s.y.s.y.s.txt == "l"