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

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

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

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

n = A("n")
a = B("a")
l = C("l")
d = D("d")
i = D("i")
k = C("k")
c = A("c")
h = D("h")
g = B("g")

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

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

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

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

n = A("n")
a = B("a")
l = C("l")
d = D("d")
i = D("i")
k = C("k")
c = A("c")
h = D("h")
g = B("g")

n.p = c
n.w = g
a.p = g
a.s = g
l.u = a
l.t = d
l.y = d
l.r = c
d.y = g
i.y = a
k.u = a
k.t = i
k.y = h
k.r = n
c.p = n
c.w = a
h.y = a
g.p = a
g.s = a
assert i.y.s.s.p.p.p.s.p.s.txt == "a"