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

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

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

b = A("b")
l = B("l")
h = C("h")
i = B("i")
g = A("g")
n = A("n")

b.x = i
l.r = h
h.p = i
i.r = h
g.x = l
n.x = l
assert b.x.r.p.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
l = B("l")
h = C("h")
i = B("i")
g = A("g")
n = A("n")

b.x = i
l.r = h
h.p = i
i.r = h
g.x = l
n.x = l
assert b.x.r.p.r.p.r.txt == "h"