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

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

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

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

d = A("d")
i = B("i")
b = C("b")
c = D("c")
n = C("n")
k = C("k")
a = A("a")

d.w = c
d.y = c
d.s = i
i.p = c
i.w = c
i.r = c
b.x = a
b.r = c
b.z = n
c.z = a
n.x = d
n.r = c
n.z = b
k.x = d
k.r = c
k.z = b
a.w = c
a.y = c
a.s = i
assert a.w.z.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: B = None
        self.y: D = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
b = C("b")
c = D("c")
n = C("n")
k = C("k")
a = A("a")

d.w = c
d.y = c
d.s = i
i.p = c
i.w = c
i.r = c
b.x = a
b.r = c
b.z = n
c.z = a
n.x = d
n.r = c
n.z = b
k.x = d
k.r = c
k.z = b
a.w = c
a.y = c
a.s = i
assert a.w.z.s.r.txt == "c"