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

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

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

d = A("d")
a = B("a")
h = C("h")
b = B("b")
i = B("i")
c = C("c")
n = B("n")

d.o = n
a.p = b
h.x = c
b.p = i
i.p = n
c.x = h
n.p = i
assert i.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
h = C("h")
b = B("b")
i = B("i")
c = C("c")
n = B("n")

d.o = n
a.p = b
h.x = c
b.p = i
i.p = n
c.x = h
n.p = i
assert i.p.p.p.txt == "n"