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

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

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

c = A("c")
h = B("h")
f = C("f")
m = C("m")
l = B("l")
a = A("a")

c.q = l
h.y = l
h.s = l
h.p = f
f.q = h
m.q = l
l.y = h
l.s = h
l.p = m
a.q = l
assert f.q.p.q.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
f = C("f")
m = C("m")
l = B("l")
a = A("a")

c.q = l
h.y = l
h.s = l
h.p = f
f.q = h
m.q = l
l.y = h
l.s = h
l.p = m
a.q = l
assert f.q.p.q.p.q.p.txt == "f"