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

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

m = A("m")
k = B("k")
f = A("f")
b = B("b")
l = B("l")
h = A("h")
a = A("a")

m.v = l
k.r = b
f.v = k
b.r = k
l.r = k
h.v = l
a.v = k
assert f.v.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

m = A("m")
k = B("k")
f = A("f")
b = B("b")
l = B("l")
h = A("h")
a = A("a")

m.v = l
k.r = b
f.v = k
b.r = k
l.r = k
h.v = l
a.v = k
assert f.v.r.r.r.r.r.txt == "b"