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

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

a = A("a")
d = B("d")
h = A("h")
c = A("c")
l = B("l")
i = A("i")
k = A("k")

a.v = h
d.s = k
h.v = a
c.v = h
l.s = c
i.v = h
k.v = c
assert l.s.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: A = None
        self.txt = txt

a = A("a")
d = B("d")
h = A("h")
c = A("c")
l = B("l")
i = A("i")
k = A("k")

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