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

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

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

a = A("a")
i = B("i")
e = C("e")
b = B("b")
k = B("k")
n = C("n")
m = C("m")
h = A("h")

a.v = m
a.p = h
i.s = k
e.r = m
e.t = m
b.s = i
k.s = b
n.r = m
n.t = m
m.r = n
m.t = n
h.v = m
h.p = a
assert i.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: A = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
e = C("e")
b = B("b")
k = B("k")
n = C("n")
m = C("m")
h = A("h")

a.v = m
a.p = h
i.s = k
e.r = m
e.t = m
b.s = i
k.s = b
n.r = m
n.t = m
m.r = n
m.t = n
h.v = m
h.p = a
assert i.s.s.s.s.s.s.txt == "i"