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

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

e = A("e")
b = B("b")
f = A("f")

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

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

e = A("e")
b = B("b")
f = A("f")

e.q = f
e.y = f
b.u = e
b.q = e
f.q = e
f.y = e
assert b.u.y.y.txt == "e"