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

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

m = A("m")
j = B("j")
n = B("n")

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

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

m = A("m")
j = B("j")
n = B("n")

m.v = n
m.o = n
j.t = n
j.z = n
n.t = j
n.z = j
assert j.t.z.z.txt == "n"