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

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

f = A("f")
l = B("l")
i = A("i")

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

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

f = A("f")
l = B("l")
i = A("i")

f.z = i
f.u = i
l.q = i
l.y = f
i.z = f
i.u = f
assert i.u.u.z.txt == "f"