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

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

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

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

c = A("c")
n = B("n")
e = C("e")
h = D("h")
a = A("a")
m = D("m")
k = A("k")
b = C("b")
g = C("g")
j = C("j")

c.w = k
c.r = b
c.s = m
n.w = m
n.y = a
e.q = a
e.p = j
h.y = a
h.x = c
h.t = n
h.u = m
a.w = c
a.r = b
a.s = h
m.y = a
m.x = c
m.t = n
m.u = h
k.w = a
k.r = b
k.s = m
b.q = k
b.p = g
g.q = k
g.p = e
j.q = a
j.p = e
assert n.y.w.s.u.x.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: C = None
        self.s: D = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
e = C("e")
h = D("h")
a = A("a")
m = D("m")
k = A("k")
b = C("b")
g = C("g")
j = C("j")

c.w = k
c.r = b
c.s = m
n.w = m
n.y = a
e.q = a
e.p = j
h.y = a
h.x = c
h.t = n
h.u = m
a.w = c
a.r = b
a.s = h
m.y = a
m.x = c
m.t = n
m.u = h
k.w = a
k.r = b
k.s = m
b.q = k
b.p = g
g.q = k
g.p = e
j.q = a
j.p = e
assert n.y.w.s.u.x.s.y.txt == "a"