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

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

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

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

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

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

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

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

f.r = h
f.t = j
f.y = e
n.t = a
a.p = j
a.o = e
e.p = k
e.o = h
j.t = h
g.r = e
g.t = n
g.y = h
k.t = h
h.p = j
h.o = e
assert k.t.o.p.t.p.t.o.o.txt == "h"