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

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

i.z = c
e.p = c
e.v = i
c.p = e
c.v = i
assert e.v.z.v.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.v: A = None
        self.txt = txt

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

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