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.txt = txt

a = A("a")
f = B("f")
l = B("l")
g = A("g")
e = B("e")

a.q = l
f.q = l
l.q = e
g.q = l
e.q = l
assert l.q.q.q.q.q.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.txt = txt

a = A("a")
f = B("f")
l = B("l")
g = A("g")
e = B("e")

a.q = l
f.q = l
l.q = e
g.q = l
e.q = l
assert l.q.q.q.q.q.txt == "e"