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

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

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

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

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

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

c.z = a
c.v = a
a.t = m
i.z = m
i.v = f
f.t = m
m.t = a
assert a.t.t.t.t.txt == "a"