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

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

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

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

m = A("m")
i = B("i")
c = C("c")
d = D("d")
k = B("k")
e = C("e")
j = A("j")

m.w = d
m.z = e
m.r = c
i.x = d
i.y = c
i.t = m
c.r = m
c.p = e
c.s = e
d.y = j
k.x = d
k.y = c
k.t = j
e.r = j
e.p = c
e.s = c
j.w = d
j.z = e
j.r = c
assert d.y.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: C = None
        self.r: C = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
c = C("c")
d = D("d")
k = B("k")
e = C("e")
j = A("j")

m.w = d
m.z = e
m.r = c
i.x = d
i.y = c
i.t = m
c.r = m
c.p = e
c.s = e
d.y = j
k.x = d
k.y = c
k.t = j
e.r = j
e.p = c
e.s = c
j.w = d
j.z = e
j.r = c
assert d.y.r.s.r.txt == "j"