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

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

b = A("b")
k = B("k")
c = A("c")

b.q = k
k.t = c
c.q = k
assert c.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

b = A("b")
k = B("k")
c = A("c")

b.q = k
k.t = c
c.q = k
assert c.q.t.q.txt == "k"