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

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

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

d = A("d")
g = B("g")
h = C("h")
e = A("e")
m = A("m")
k = A("k")
n = A("n")
c = B("c")

d.x = h
d.p = c
d.t = g
g.w = h
h.r = c
h.o = n
e.x = h
e.p = g
e.t = c
m.x = h
m.p = c
m.t = g
k.x = h
k.p = c
k.t = c
n.x = h
n.p = g
n.t = g
c.w = h
assert n.t.w.o.t.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: B = None
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
g = B("g")
h = C("h")
e = A("e")
m = A("m")
k = A("k")
n = A("n")
c = B("c")

d.x = h
d.p = c
d.t = g
g.w = h
h.r = c
h.o = n
e.x = h
e.p = g
e.t = c
m.x = h
m.p = c
m.t = g
k.x = h
k.p = c
k.t = c
n.x = h
n.p = g
n.t = g
c.w = h
assert n.t.w.o.t.w.r.w.r.txt == "c"