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

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

e = A("e")
c = B("c")
j = A("j")
i = B("i")

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

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

e = A("e")
c = B("c")
j = A("j")
i = B("i")

e.p = c
c.z = j
j.p = i
i.z = j
assert e.p.z.p.z.txt == "j"