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

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

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

c.u = e
c.s = f
e.z = f
f.u = e
f.s = c
assert f.s.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: A = None
        self.txt = txt

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

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

c.u = e
c.s = f
e.z = f
f.u = e
f.s = c
assert f.s.s.u.txt == "e"