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

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

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

b = A("b")
k = B("k")
h = C("h")
g = A("g")
a = A("a")
l = A("l")

b.v = g
k.p = b
h.o = k
g.v = b
a.v = l
l.v = a
assert l.v.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.p: A = None
        self.txt = txt

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

b = A("b")
k = B("k")
h = C("h")
g = A("g")
a = A("a")
l = A("l")

b.v = g
k.p = b
h.o = k
g.v = b
a.v = l
l.v = a
assert l.v.v.v.v.v.v.txt == "l"