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

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

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

c = A("c")
e = B("e")
f = C("f")
a = A("a")
l = B("l")
d = B("d")
h = A("h")
j = C("j")

c.q = j
e.y = f
f.s = e
a.q = j
l.y = f
d.y = f
h.q = f
j.s = d
assert a.q.s.y.s.y.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
f = C("f")
a = A("a")
l = B("l")
d = B("d")
h = A("h")
j = C("j")

c.q = j
e.y = f
f.s = e
a.q = j
l.y = f
d.y = f
h.q = f
j.s = d
assert a.q.s.y.s.y.s.y.s.txt == "e"