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: A = None
        self.txt = txt

b = A("b")
h = B("h")
j = B("j")
d = B("d")
f = B("f")
k = B("k")

b.z = h
b.s = f
h.p = b
j.p = b
d.p = b
f.p = b
k.p = b
assert k.p.z.p.s.p.s.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: A = None
        self.txt = txt

b = A("b")
h = B("h")
j = B("j")
d = B("d")
f = B("f")
k = B("k")

b.z = h
b.s = f
h.p = b
j.p = b
d.p = b
f.p = b
k.p = b
assert k.p.z.p.s.p.s.txt == "f"