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

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

k = A("k")
d = B("d")
l = B("l")

k.v = l
d.q = l
l.q = d
assert l.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
l = B("l")

k.v = l
d.q = l
l.q = d
assert l.q.q.q.txt == "d"