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

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

k = A("k")
d = B("d")
c = B("c")
m = A("m")
h = A("h")
l = A("l")

k.v = m
d.s = c
c.s = d
m.v = l
h.v = k
l.v = h
assert m.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

k = A("k")
d = B("d")
c = B("c")
m = A("m")
h = A("h")
l = A("l")

k.v = m
d.s = c
c.s = d
m.v = l
h.v = k
l.v = h
assert m.v.v.v.v.v.txt == "l"