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

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

k = A("k")
m = B("m")
d = A("d")
b = A("b")
a = A("a")
c = A("c")

k.t = d
k.v = m
m.y = k
d.t = b
d.v = m
b.t = a
b.v = m
a.t = k
a.v = m
c.t = b
c.v = m
assert c.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
d = A("d")
b = A("b")
a = A("a")
c = A("c")

k.t = d
k.v = m
m.y = k
d.t = b
d.v = m
b.t = a
b.v = m
a.t = k
a.v = m
c.t = b
c.v = m
assert c.v.y.v.txt == "m"