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

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

f = A("f")
m = B("m")
a = B("a")
k = A("k")

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

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

f = A("f")
m = B("m")
a = B("a")
k = A("k")

f.z = m
f.t = m
m.v = a
a.v = m
k.z = m
k.t = m
assert k.t.v.v.v.txt == "a"