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

i = A("i")
l = B("l")
n = B("n")

i.q = l
l.y = n
n.y = l
assert n.y.y.y.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.txt = txt

i = A("i")
l = B("l")
n = B("n")

i.q = l
l.y = n
n.y = l
assert n.y.y.y.txt == "l"