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

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

k = A("k")
c = B("c")
n = A("n")
e = B("e")

k.q = n
c.u = e
n.q = k
e.u = c
assert k.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

k = A("k")
c = B("c")
n = A("n")
e = B("e")

k.q = n
c.u = e
n.q = k
e.u = c
assert k.q.q.q.txt == "n"