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

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

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

h = A("h")
c = B("c")
a = C("a")
m = A("m")
b = B("b")
k = C("k")

h.p = m
c.t = k
a.p = k
m.p = h
b.t = k
k.p = a
assert c.t.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
a = C("a")
m = A("m")
b = B("b")
k = C("k")

h.p = m
c.t = k
a.p = k
m.p = h
b.t = k
k.p = a
assert c.t.p.p.p.p.txt == "k"