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

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

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

f = A("f")
b = B("b")
g = C("g")
j = C("j")
h = B("h")
e = C("e")
d = B("d")
n = B("n")
i = C("i")
c = A("c")

f.q = d
b.s = h
g.y = n
g.s = d
j.y = h
j.s = d
h.s = n
e.y = b
e.s = n
d.s = b
n.s = d
i.y = b
i.s = h
c.q = d
assert i.y.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
g = C("g")
j = C("j")
h = B("h")
e = C("e")
d = B("d")
n = B("n")
i = C("i")
c = A("c")

f.q = d
b.s = h
g.y = n
g.s = d
j.y = h
j.s = d
h.s = n
e.y = b
e.s = n
d.s = b
n.s = d
i.y = b
i.s = h
c.q = d
assert i.y.s.s.s.s.s.txt == "h"