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

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

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

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

n = A("n")
d = B("d")
c = C("c")
g = D("g")
f = A("f")
m = C("m")
i = D("i")

n.w = d
n.s = m
n.r = g
d.z = n
c.z = m
c.t = f
c.y = i
g.u = f
f.w = d
f.s = c
f.r = i
m.z = c
m.t = n
m.y = i
i.u = f
assert n.w.z.r.u.r.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: C = None
        self.r: D = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
c = C("c")
g = D("g")
f = A("f")
m = C("m")
i = D("i")

n.w = d
n.s = m
n.r = g
d.z = n
c.z = m
c.t = f
c.y = i
g.u = f
f.w = d
f.s = c
f.r = i
m.z = c
m.t = n
m.y = i
i.u = f
assert n.w.z.r.u.r.u.s.txt == "c"