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

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

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

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

j = A("j")
i = B("i")
m = C("m")
g = D("g")
n = A("n")
l = B("l")
e = C("e")
k = B("k")
a = C("a")

j.p = m
j.r = i
j.o = e
j.w = e
i.z = g
m.p = k
m.y = e
m.r = g
g.p = k
g.r = k
n.p = a
n.r = k
n.o = e
n.w = e
l.z = g
e.p = i
e.y = m
e.r = g
k.z = g
a.p = i
a.y = e
a.r = g
assert l.z.p.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: B = None
        self.o: C = None
        self.w: C = None
        self.txt = txt

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

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

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

j = A("j")
i = B("i")
m = C("m")
g = D("g")
n = A("n")
l = B("l")
e = C("e")
k = B("k")
a = C("a")

j.p = m
j.r = i
j.o = e
j.w = e
i.z = g
m.p = k
m.y = e
m.r = g
g.p = k
g.r = k
n.p = a
n.r = k
n.o = e
n.w = e
l.z = g
e.p = i
e.y = m
e.r = g
k.z = g
a.p = i
a.y = e
a.r = g
assert l.z.p.z.r.z.txt == "g"