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

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

b = A("b")
f = B("f")
h = A("h")
a = A("a")
n = B("n")
j = B("j")
l = A("l")

b.q = f
f.q = n
f.s = j
h.q = n
a.q = j
n.q = f
n.s = f
j.q = f
j.s = f
l.q = f
assert a.q.q.s.q.q.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.q: B = None
        self.s: B = None
        self.txt = txt

b = A("b")
f = B("f")
h = A("h")
a = A("a")
n = B("n")
j = B("j")
l = A("l")

b.q = f
f.q = n
f.s = j
h.q = n
a.q = j
n.q = f
n.s = f
j.q = f
j.s = f
l.q = f
assert a.q.q.s.q.q.s.s.txt == "j"