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

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

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

d = A("d")
i = B("i")
j = C("j")
f = A("f")
a = C("a")
n = B("n")
h = B("h")
k = B("k")
g = B("g")

d.p = i
i.p = k
i.r = f
i.s = d
j.o = d
j.t = d
j.u = g
f.p = n
a.o = f
a.t = d
a.u = i
n.p = h
n.r = f
n.s = d
h.p = k
h.r = d
h.s = d
k.p = g
k.r = f
k.s = d
g.p = k
g.r = f
g.s = d
assert d.p.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
j = C("j")
f = A("f")
a = C("a")
n = B("n")
h = B("h")
k = B("k")
g = B("g")

d.p = i
i.p = k
i.r = f
i.s = d
j.o = d
j.t = d
j.u = g
f.p = n
a.o = f
a.t = d
a.u = i
n.p = h
n.r = f
n.s = d
h.p = k
h.r = d
h.s = d
k.p = g
k.r = f
k.s = d
g.p = k
g.r = f
g.s = d
assert d.p.p.r.p.txt == "n"