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

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

k = A("k")
d = B("d")
e = A("e")
f = B("f")

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

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

k = A("k")
d = B("d")
e = A("e")
f = B("f")

k.u = e
d.q = k
e.u = k
f.q = k
assert k.u.u.u.txt == "e"