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

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

c = A("c")
e = B("e")
h = A("h")
b = A("b")
j = B("j")
f = B("f")

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

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

c = A("c")
e = B("e")
h = A("h")
b = A("b")
j = B("j")
f = B("f")

c.z = j
e.p = f
h.z = f
b.z = f
j.p = e
f.p = j
assert b.z.p.p.p.p.txt == "j"