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

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

i = A("i")
e = B("e")
k = B("k")

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

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

i = A("i")
e = B("e")
k = B("k")

i.u = k
e.q = k
k.q = e
assert e.q.q.q.txt == "k"