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

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

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

m.x = i
m.v = i
a.t = i
c.x = a
c.v = i
i.t = a
e.x = i
e.v = a
assert c.x.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.txt = txt

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

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

m.x = i
m.v = i
a.t = i
c.x = a
c.v = i
i.t = a
e.x = i
e.v = a
assert c.x.t.t.t.t.txt == "a"