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

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

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

k = A("k")
f = B("f")
n = C("n")
e = B("e")
m = B("m")
d = A("d")
a = B("a")
c = C("c")

k.x = d
k.r = d
k.y = d
f.p = e
f.t = e
f.w = n
n.y = c
e.p = m
e.t = a
e.w = n
m.p = e
m.t = a
m.w = n
d.x = k
d.r = k
d.y = k
a.p = e
a.t = m
a.w = n
c.y = n
assert m.t.p.p.p.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: A = None
        self.y: A = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
n = C("n")
e = B("e")
m = B("m")
d = A("d")
a = B("a")
c = C("c")

k.x = d
k.r = d
k.y = d
f.p = e
f.t = e
f.w = n
n.y = c
e.p = m
e.t = a
e.w = n
m.p = e
m.t = a
m.w = n
d.x = k
d.r = k
d.y = k
a.p = e
a.t = m
a.w = n
c.y = n
assert m.t.p.p.p.p.t.txt == "a"