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

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

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

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

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

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

c.y = i
n.q = i
n.t = c
i.q = n
i.t = c
assert i.q.q.t.txt == "c"