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

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

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

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

h.p = d
h.x = e
e.y = f
e.s = a
g.p = d
g.s = k
g.u = f
a.y = f
a.s = e
k.p = d
k.s = f
k.u = g
f.p = d
f.s = k
f.u = k
i.p = l
i.x = a
l.p = h
l.x = e
d.p = m
d.x = e
m.p = l
m.x = a
assert f.p.p.p.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: B = None
        self.txt = txt

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

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

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

h.p = d
h.x = e
e.y = f
e.s = a
g.p = d
g.s = k
g.u = f
a.y = f
a.s = e
k.p = d
k.s = f
k.u = g
f.p = d
f.s = k
f.u = k
i.p = l
i.x = a
l.p = h
l.x = e
d.p = m
d.x = e
m.p = l
m.x = a
assert f.p.p.p.x.s.txt == "a"