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

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

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

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

h.y = i
h.p = k
a.o = i
k.o = i
k.t = i
k.r = n
n.y = a
n.p = k
i.o = a
m.o = a
m.t = i
m.r = n
assert i.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: C = None
        self.txt = txt

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

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

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

h.y = i
h.p = k
a.o = i
k.o = i
k.t = i
k.r = n
n.y = a
n.p = k
i.o = a
m.o = a
m.t = i
m.r = n
assert i.o.o.o.o.o.o.txt == "i"