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

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

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

h = A("h")
a = B("a")
m = C("m")
g = B("g")
d = A("d")
f = A("f")
k = A("k")
n = B("n")
l = A("l")

h.p = m
a.y = h
m.r = h
m.u = g
m.p = l
g.y = l
d.p = m
f.p = m
k.p = m
n.y = k
l.p = m
assert a.y.p.r.p.u.y.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
m = C("m")
g = B("g")
d = A("d")
f = A("f")
k = A("k")
n = B("n")
l = A("l")

h.p = m
a.y = h
m.r = h
m.u = g
m.p = l
g.y = l
d.p = m
f.p = m
k.p = m
n.y = k
l.p = m
assert a.y.p.r.p.u.y.p.u.txt == "g"