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

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

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

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

n.t = f
n.p = d
d.u = a
d.o = c
h.u = f
h.w = n
b.u = k
b.o = d
f.t = n
f.p = c
c.u = h
c.o = b
l.u = h
l.o = g
g.u = k
g.o = c
k.u = n
k.w = f
a.u = f
a.w = n
assert g.u.u.p.o.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.txt = txt

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

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

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

n.t = f
n.p = d
d.u = a
d.o = c
h.u = f
h.w = n
b.u = k
b.o = d
f.t = n
f.p = c
c.u = h
c.o = b
l.u = h
l.o = g
g.u = k
g.o = c
k.u = n
k.w = f
a.u = f
a.w = n
assert g.u.u.p.o.u.w.txt == "n"