class A:
    def __init__(self, txt: str):
        self.q: 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.s: B = None
        self.txt = txt

d = A("d")
g = B("g")
l = C("l")
h = B("h")
b = B("b")
k = A("k")
c = A("c")

d.q = l
g.s = l
l.s = h
h.s = l
b.s = l
k.q = l
c.q = l
assert k.q.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: 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.s: B = None
        self.txt = txt

d = A("d")
g = B("g")
l = C("l")
h = B("h")
b = B("b")
k = A("k")
c = A("c")

d.q = l
g.s = l
l.s = h
h.s = l
b.s = l
k.q = l
c.q = l
assert k.q.s.s.s.txt == "h"