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

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

f = A("f")
n = B("n")
g = B("g")

f.o = n
f.s = n
n.z = f
n.y = g
g.z = f
g.y = n
assert g.z.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: B = None
        self.txt = txt

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

f = A("f")
n = B("n")
g = B("g")

f.o = n
f.s = n
n.z = f
n.y = g
g.z = f
g.y = n
assert g.z.o.y.txt == "g"