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

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

j = A("j")
b = B("b")
e = B("e")
m = A("m")

j.z = m
j.o = e
b.t = e
b.v = e
e.t = b
e.v = b
m.z = j
m.o = e
assert b.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: B = None
        self.txt = txt

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

j = A("j")
b = B("b")
e = B("e")
m = A("m")

j.z = m
j.o = e
b.t = e
b.v = e
e.t = b
e.v = b
m.z = j
m.o = e
assert b.t.t.t.t.txt == "b"