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

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

n = A("n")
c = B("c")
h = A("h")

n.s = c
n.z = c
c.r = h
c.s = n
h.s = c
h.z = c
assert h.s.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

n = A("n")
c = B("c")
h = A("h")

n.s = c
n.z = c
c.r = h
c.s = n
h.s = c
h.z = c
assert h.s.r.z.txt == "c"