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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

e.z = b
e.s = h
h.p = b
h.v = b
b.p = h
b.v = h
assert h.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

e.z = b
e.s = h
h.p = b
h.v = b
b.p = h
b.v = h
assert h.v.p.v.txt == "b"