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

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

l = A("l")
m = B("m")
e = B("e")

l.q = m
m.t = e
e.t = m
assert e.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

l = A("l")
m = B("m")
e = B("e")

l.q = m
m.t = e
e.t = m
assert e.t.t.t.txt == "m"