class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

e = A("e")
i = B("i")
h = C("h")
g = D("g")
j = C("j")
f = A("f")
n = C("n")
a = B("a")
m = D("m")

e.x = m
e.w = m
i.z = m
i.y = g
i.r = g
h.s = m
h.r = j
h.q = n
g.y = n
g.p = f
j.s = g
j.r = h
j.q = n
f.x = g
f.w = m
n.s = g
n.r = h
n.q = h
a.z = m
a.y = m
a.r = g
m.y = h
m.p = f
assert j.s.y.s.p.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

e = A("e")
i = B("i")
h = C("h")
g = D("g")
j = C("j")
f = A("f")
n = C("n")
a = B("a")
m = D("m")

e.x = m
e.w = m
i.z = m
i.y = g
i.r = g
h.s = m
h.r = j
h.q = n
g.y = n
g.p = f
j.s = g
j.r = h
j.q = n
f.x = g
f.w = m
n.s = g
n.r = h
n.q = h
a.z = m
a.y = m
a.r = g
m.y = h
m.p = f
assert j.s.y.s.p.w.p.w.txt == "m"